so im trying to build an app using GCM. i've opened 2 modules for this. a backend (GCM messaging with appengine and a regular module - the names are "app" (regular module" and "backend").
i'm recieving this problem and i can't figure the solotion for it.
when the app is starting i get the following error:
10-04 18:24:16.391 18920-18920/com.example.daniel.testing6 E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$attr
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:289)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.example.daniel.testing6.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
My project name is Testing6 and its gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
my app module gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "com.example.daniel.testing6"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true // i added it because i got different problem
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile project(path: ':backend', configuration: 'android-endpoints')
}
and my backend module:
// If you would like more information on the gradle-appengine-plugin please refer to the github page
// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.18'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18'
compile 'com.google.appengine:appengine-endpoints:1.9.18'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.18'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.googlecode.objectify:objectify:4.0b3'
compile 'com.ganyo:gcm-server:1.0.2'
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}
public class MainActivity extends MultiDexApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
doew anyone knows how to fix it???
Problem Solved!
Ok so i did the following:
manifast:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.daniel.testing6" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.example.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
<application
android:name="com.example.daniel.testing6.Application"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Main2Activity"
android:label="#string/title_activity_main2"
android:theme="#style/AppTheme.NoActionBar" >
</activity>
</application>
</manifest>
ok so to get rid of the error i went to the gradle of my module app:
so it will look like that:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "com.example.daniel.testing6"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(path: ':backend', configuration: 'android-endpoints')
//
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:design:22.2.1'
}
next i created an Application as follows:
package com.example.daniel.testing6;
import android.content.Context;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;
/**
* Created by Daniel on 05-Oct-15.
*/
public class Application extends MultiDexApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
and a main activity normally:
package com.example.daniel.testing6;
import android.content.Context;
import android.content.Intent;
import android.os.PersistableBundle;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startActivity(new Intent(this, Main2Activity.class));
}
}
the manifast calls the Application that uploading all its data and then moves to the activity once the data is with in our reach :)
You also have to:
Include `compile 'com.android.support:multidex:1.0.0'` in your dependencies
See https://developer.android.com/tools/building/multidex.html for more details.
Also have your Application class extend MultiDexApplication instead of just Application. Alternatively, you can call MultiDex.install() in attachBaseContext() of your application
Installing/updating Android Support Library and Android Support Repository in SDK manager will fix such errors
Related
I have a Android Studio project which I tested on API 30 and is working fine. Now I tried running it on API 26 (which is the minimum SDK version I set for the project) and I can't get the app to start.
Both times I used an emulated Pixel 3a and one external device.
Error Log:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.main.xyz, PID: 9389
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.main.xyz/com.main.xyz.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.main.xyz.MainActivity" on path: DexPathList[[zip file "/data/app/com.main.xyz-rZkYLBaLo3gdkb7oCChonQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.main.xyz-rZkYLBaLo3gdkb7oCChonQ==/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2718)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.main.xyz.MainActivity" on path: DexPathList[[zip file "/data/app/com.main.xyz-rZkYLBaLo3gdkb7oCChonQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.main.xyz-rZkYLBaLo3gdkb7oCChonQ==/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1173)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Suppressed: java.io.IOException: Failed to open dex files from /data/app/com.main.xyz-rZkYLBaLo3gdkb7oCChonQ==/base.apk because: Failure to verify dex file '/data/app/com.main.xyz-rZkYLBaLo3gdkb7oCChonQ==/base.apk': Bad method handle type 7
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:353)
at dalvik.system.DexFile.<init>(DexFile.java:100)
at dalvik.system.DexFile.<init>(DexFile.java:74)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
at dalvik.system.DexPathList.<init>(DexPathList.java:157)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:36)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:676)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:709)
at android.app.LoadedApk.getResources(LoadedApk.java:936)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2242)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5672)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
... 6 more
My MainActivity.java:
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
//Called by Button
public void login(View v) {
Intent intent = new Intent(MainActivity.this, Uebersicht.class);
startActivity(intent)
}
My build.gradle (app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "com.main.xyz"
minSdkVersion 26
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
proguardFiles 'proguard-rules.pro'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.android.gms:play-services-vision:20.1.0'
}
My build.grade (project):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And my manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.main.xyz">
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:usesCleartextTraffic="true">
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Uebersicht"
android:label="" />
<activity
android:name=".ProductActivity"
android:label="" />
<activity
android:name=".AddActivity"
android:label=""/>
<activity
android:name=".ScanActivity"
android:label="" />
</application>
</manifest>
I've been looking for a solution for quite a while now. As I'm pretty new to Android all help is deeply appreciated. If you can provide it I'd really to have an explaination to my problem as well as a solution to be able to understand what's going wrong here.
I guess it is a problem with dexing , so try to add this library in your dependencies gradle , so do as following :
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.android.gms:play-services-vision:20.1.0'
implementation 'com.android.support:multidex:1.0.3' // add this library
}
and here add this code
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "com.main.xyz"
minSdkVersion 26
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
proguardFiles 'proguard-rules.pro'
multiDexEnabled true // add this line of code
}
I looked into the dexing error description and found another question regarding java 8 support. Implementing
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
and
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'
into the app's build.gradle file solved the problem.
More information here
In my main Activity right after i try to initialize the two references it crashes, only to find out the error "FirebaseApp initialization unsuccessful"
private StorageReference mStorageReference;
private DatabaseReference mDatabaseReference;
mStorageReference = FirebaseStorage.getInstance().getReference("uploads");
mDatabaseReference = FirebaseDatabase.getInstance().getReference("uploads");
there is some code between the private declaration and the code itself, but that is not relevant to this problem
The manifest is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.firebase10">
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The build.gradle(Project):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The build.gradle(app):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.firebase10"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-
optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api "com.google.android.gms:play-services-base:15.0.1"
api "com.google.android.gms:play-services-auth:16.0.0"
api "com.google.android.gms:play-services-identity:15.0.1"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.android.support:customtabs:28.0.0"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.gms:google-services:4.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
}
I set up everything with Tools-Firebase, and i know that the code looks like it is glued together, since it is. I've been going through threads and just added things but nothing worked. If this matters, i am running the app on my phone, not emulator.
Is your google-json file is well setted ?
Also Firebase needs time to connect to it server and gives you the instance referred to your device , give it some time or use a promise to make sure firebase is connected to it server and instance is generated, then perform the action that need firebase instance.
In build.gradle(Project) I Changed 'com.google.gms:google-services:4.1.0' To 'com.google.gms:google-services:4.2.0' and the problem is solved
This one here is non-sense, because that's a Gradle plugin:
dependencies {
implementation 'com.google.gms:google-services:4.2.0'
}
And this one belong to the bottom of the file:
apply plugin: 'com.google.gms.google-services'
The error says that "Error:Execution failed for task ':app:processDebugManifest'. > "
I have tried many solutions on this website but still, the problem is not solved. Please help me
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="project.myapp">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:appComponentFactory">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle(Module:app)
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
android {
compileSdkVersion 28
defaultConfig {
applicationId "project.myapp"
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
// implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-auth:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
implementation 'com.firebaseui:firebase-ui-firestore:3.0.0'
implementation 'de.hdodenhof:circleimageview:2.0.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
build.gradle(Project:myapp)
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
On Merged Manifest says that
Merging Errors: Error: tools:replace specified at line:5 for attribute
android:appComponentFactory, but no new value specified app main
manifest (this file), line 4 Error: Validation failed, exiting app
main manifest (this file)
For me, the solution was to just migrate to AndroidX.
On Android Studio, go to:
Refactor > Migrate to AndroidX
clean the project.
I.m delete this
tools:ignore="GoogleAppIndexingWarning",
tools:replace="android:appComponentFactory"
and fix this problem.good luck :)
Just remove the below line:
tools:replace="android:appComponentFactory"
And recompile and finally it works for me!
you should try this:
1:Remove tools:replace="android:appComponentFactory"
2:Provide new value for android:appComponentFactory" attribute
from:
Manifest merger failed, error on compiling
it worked for me!
solve my problem
Refactor > Migrate to AndroidX
In my case an error in Manifest file brought about this error at the time of generating apk although app was building flawlessly.
It was want of explicit 'exported' attribute in activity elements in Manifest file. after that apk too generated successfully .
I've recently had to enable multidex in my android studio project, this is built with imported module. It's doing well in the main project, but showing multidex problem in the project built with imported(from the main project) module. I have followed this documentation to enable multidex. As the application tag is not overridden , so i've followed the method related. Now i'm getting this error:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [E:\something\SalesDemo >Updated\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't >read [E:\something\SalesDemo >Updated\app\build\intermediates\classes\debug(;;;;;;**.class)] (Can't read [com] >(Can't read [smth] (Can't read [infolinkplus] (Can't read
[some.class] (Duplicate zip entry
[com/abc/def/some.class]))))))
Here's my build.gradle:
apply plugin: 'com.android.application'
//noinspection GroovyMissingReturnStatement
android {
compileSdkVersion 25
// buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.abc.def.somethingotherthing"
multiDexEnabled true
minSdkVersion 16
//noinspection OldTargetApi
targetSdkVersion 22
versionCode 16
versionName "0.0.16"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//implementation 'com.android.support:multidex:1.0.3'
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.3'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'joda-time:joda-time:2.3'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile project(':infolinkplus')
}
And the manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.abc.def.somethingotherthing">
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
...
//ACTIVITIES AND META-TAGS
...
</application>
</manifest>
After changes, i ran clean build and rebuilt but no result.
How can i overcome this problem? Thanks in advance.
You have to change your Manifest to provide MultiDex:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
or if you have custom Application class, you have to extend it with MultiDexApplication
public class MyApplication extends MultiDexApplication { ... }
Duplicate zip entry
[com/abc/def/some.class]
In your project you must be having a class with name some.class rename it to some thing else
Try this code...
i hope you done this things..
multiDexEnabled true
compile 'com.android.support:multidex:1.0.1'
make class for application level..
public class MyApplication extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
}
}
android:name="MyApplication" > // here define that class name that extends by MultiDexApplication
After updating kotlin to RC-1036 i'm facing a weird issue: my code is not even compiled and packed.
When build passes and the app is launched i'm getting ClassNotFoundException: Didn't find class "example.myapplication.MainActivity".
I have tried to decompile apk with apktool and didn't find my classes inside the archive. There are no classes in build/intermediates dir either.
This is my project:
app/build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
buildscript {
ext.kotlin_version = '1.0.0-rc-1036'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "example.myapplication"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="example.myapplication"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
And MainActivity:
package example.myapplication
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
hello.text = "New text"
}
}
Build tools version is 2.0.0-beta2;
Might be something wrong with sourseSets, though nothing works if i try to reconfigure it somehow. Appreciate any help.
You should have both these plugins:
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
The first makes sure the Kotlin code compiles, the second is for the UI imports.