i got simmilar post but nothing working
i have android studio 2.3.1
gradle version 2.3.1
appcompat-v7:25.3.1
I create a new project by android studio(one that is automatically created by Android Studio(Hello Word)). I haven't write any thing in it.
When i install app using usb via android studio it works perfectly
but same app if i open it from it's icon ,i got these errors
One more i noticed that size of apk is 500-600kb ,early it used to be around for hello world(default by android studio) Apk 2.3Mb
FATAL EXCEPTION: main
Process: in.codebucket.check, PID: 32397
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{in.codebucket.check/in.codebucket.check.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "in.codebucket.check.MainActivity" on path: DexPathList[[zip file "/data/app/in.codebucket.check-1/base.apk"],nativeLibraryDirectories=[/data/app/in.codebucket.check-1/lib/x86, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "in.codebucket.check.MainActivity" on path: DexPathList[[zip file "/data/app/in.codebucket.check-1/base.apk"],nativeLibraryDirectories=[/data/app/in.codebucket.check-1/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Suppressed: java.lang.ClassNotFoundException: in.codebucket.check.MainActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
My xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.codebucket.check.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
My MainActivity
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}}
my Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.codebucket.check">
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
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>
</manifest>
gradle(Module:App)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "in.codebucket.check"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}}}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-
core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
gradle(Project)
// 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:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Got the solution ,it is happening because of instant run,
Just disable it
Goto :
Android Studio --> File --> Setting --> Build, execution, deploy --> Instant run.
No need to disable instant run, just remove the app from device/emulator and clean the project and install it again.
For me the problem was that the Gradle dependencies wen't matching. Here's what solved it for me:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.and.myApp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-fexceptions"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'jp.wasabeef:blurry:2.1.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
//noinspection GradleCompatible
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.+'
}
For me, it is after I add the code to use getFusedLocationProviderClient, I get crashes
process: no.onmyway133.myapp, PID: 10538
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/Api$zzf;
at com.google.android.gms.location.LocationServices.<clinit>(Unknown Source)
at com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(Unknown Source)
at no.onmyway133.myapp.maps.MapsActivity.onCreate(MapsActivity.kt:22)
The problem is the warning in build.gradle, it warns that both should use the same version, otherwise there will be potential for runtime crashes.
So the fix is to specify the same version
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation "com.google.android.gms:play-services-location:15.0.1"
Related
I'm pretty sure that my project was working before I moved the project into another folder, and then I moved it back to the original folder while it was open in Android Studios. When I run it it now has an error caused by
java.lang.ClassNotFoundException
Do you think moving the project could have caused this? I've checked other answers and I think my manifest and build.gradle are ok.
Module build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.1'
defaultConfig {
applicationId "com.example.larry.project"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.code.gson:gson:2.7'
testCompile 'junit:junit:4.12'
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.larry.project">
<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"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Project build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
These are mostly just defaults, i dont see how it could cause a problem.
And the error:
11-12 15:55:25.405 4745-4745/com.example.larry.project E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.larry.project, PID: 4745
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.larry.project/com.example.larry.project.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.larry.project.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.larry.project-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.larry.project-1/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.larry.project.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.larry.lproject-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.larry.project-1/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
I have fixed my question and am reposting it.
My app was running well but it is crashing now. I started getting warnings even though I am not integrating with firebase. Now I think that I can not solve this problem. I tried every possible solution available on stackoverflow. Also, I am using viewpager in my code if that helps.
LogCat
W/Ads: Invoke Firebase method getInstance error.
java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.measurement.AppMeasurement" on path: DexPathList[[zip file "/data/app/com.kidsbox.android.abcforkidsalphabetshapesandnumbers-1/base.apk"],nativeLibraryDirectories=[/data/app/com.kidsbox.android.abcforkidsalphabetshapesandnumbers-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.google.android.gms.ads.internal.scionintegration.b.a(:com.google.android.gms.DynamiteModulesA:167)
at com.google.android.gms.ads.internal.scionintegration.b.a(:com.google.android.gms.DynamiteModulesA:152)
at com.google.android.gms.ads.internal.scionintegration.b.g(:com.google.android.gms.DynamiteModulesA:43)
at com.google.android.gms.ads.internal.request.c.a(:com.google.android.gms.DynamiteModulesA:26)
at com.google.android.gms.ads.internal.util.b.run(:com.google.android.gms.DynamiteModulesA:4)
at com.google.android.gms.ads.internal.util.af.call(:com.google.android.gms.DynamiteModulesA:3)
at com.google.android.gms.ads.internal.util.ag.run(:com.google.android.gms.DynamiteModulesA:3)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.measurement.AppMeasurement
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kidsbox.android.abcforkidsalphabetshapesandnumbers">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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>
<activity android:name=".Alphabet" />
<activity android:name=".Number" />
<activity android:name=".Shapes"/>
</application>
Build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.kidsbox.android.abcforkidsalphabetshapesandnumbers"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.android.gms:play-services-ads:11.0.4'
testCompile 'junit:junit:4.12'
}
I think this issue is similar with How to enable multidexing with the new Android Multidex support library
Add implementation "com.android.support:multidex:1.0.1" in your build.gradle's dependencies ( implementation can be replaced with compile );
Add a custom application extends from Application. Add code as below:
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
MultiDex.install(this)
}
Add your custom application in AnroidManifest.xml as android:name=".CustomApplication"
You should use compile 'com.google.firebase:firebase-ads:11.2.0'
instead of compile 'com.google.android.gms:play-services-ads:11.2.0'
I am trying to do some experiments with Instant Apps Documentation: Android Instant Apps
Native Android apps, without the installation. I have followed steps which are covered on official docs. I have created emulator Nexus 5X to test instant apps features.
So, I have created two features in my project, which is much similar just kinda of demo to see how instant apps works. It was working well on one feature, now after when I created one more feature, now I have two features which in turns crashing my application.
05-24 12:07:12.259 12020-12028/? E/art: Failed writing handshake bytes (-1 of 14): Broken pipe
05-24 12:07:15.952 12020-12020/com.williams.instantappdemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.williams.instantappdemo, PID: 12020
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.williams.instantappdemo/com.williams.instantappdemo.feature.MainActivity}: java.lang.ClassNotFoundException: could not find com.williams.instantappdemo.feature.MainActivity in any atom class loader or parent class loader
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: could not find com.williams.instantappdemo.feature.MainActivity in any atom class loader or parent class loader
at com.google.android.instantapps.supervisor.loader.WhAppClassLoader.loadClass(WhAppClassLoader.java:100)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Suppressed: java.lang.ClassNotFoundException: Didn't find class "com.williams.instantappdemo.feature.MainActivity" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib, /vendor/lib, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.android.instantapps.supervisor.loader.WhAppClassLoader.loadClass(WhAppClassLoader.java:85)
... 11 more
Suppressed: java.lang.ClassNotFoundException: Didn't find class "com.williams.instantappdemo.feature.MainActivity" on path: DexPathList[[zip file "/data/user/0/com.google.android.instantapps.supervisor/files/atom-cache/com.williams.instantappdemo/atom-download--base-1495607829279/base.jar"],nativeLibraryDirectories=[/data/user/0/com.google.android.instantapps.supervisor/files/native-lib/com.williams.instantappdemo, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at com.google.android.instantapps.supervisor.loader.DexFirstClassLoader.doLoadClass(DexFirstClassLoader.java:50)
at com.google.android.instantapps.supervisor.loader.WhAppClassLoader.loadClass(WhAppClassLoader.java:92)
... 11 more
Suppressed: java.lang.ClassNotFoundException: Didn't find class "com.williams.instantappdemo.feature.MainActivity" on path: DexPathList[[zip file "/data/user/0/com.google.android.instantapps.supervisor/files/atom-cache/com.williams.instantappdemo/atom-download--feature-1495607829279/feature.jar"],nativeLibraryDirectories=[/data/user/0/com.google.android.instantapps.supervisor/files/native-lib/com.williams.instantappdemo, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at com.google.android.instantapps.supervisor.loader.DexFirstClassLoader.doLoadClass(DexFirstClassLoader.java:50)
at com.google.android.instantapps.supervisor.loader.WhAppClassLoader.loadClass(WhAppClassLoader.java:92)
... 11 more
Here is build.gradle of feature module:
apply plugin: 'com.android.feature'
android {
compileSdkVersion 25
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation project(':base')
testCompile 'junit:junit:4.12'
}
Here is build.gradle for feature2:
apply plugin: 'com.android.feature'
android {
compileSdkVersion 25
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation project(':base')
testCompile 'junit:junit:4.12'
}
Here is the build.gradle for base module:
apply plugin: 'com.android.feature'
android {
compileSdkVersion 25
buildToolsVersion rootProject.buildToolsVersion
baseFeature true
defaultConfig {
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
feature project(':feature')
compile 'com.android.support:appcompat-v7:25.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
feature project(":feature1")
}
Here is the build.gradle of app module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
applicationId "com.nagarro.instantappdemo"
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(':feature')
implementation project(':feature1')
implementation project(':base')
}
Can anyone suggest what I am doing wrong ?
It looks like the actual activity package doesn't match what you have in your manifest file of the feature that contains MainActivity. It's a common error when refactoring activities into new packages and not using relative paths for activities in the manifest. Fully qualify the path to be absolutely sure
<activity android:name="com.williams.instantappdemo.feature.MainActivity"/>
Inspect the the apk file (build/outputs/apks) using Apk Analyzer to see if it has com.williams.instantappdemo.feature.MainActivity in that exact package.
You can also use the Merged Manifest view to inspect your final manifest (app module) to verify everything is in order.
Also, add application project(":app") to the base feature module so that it uses applicationId defined in your app module to package your app/instant app
Update:
Using the techniques described above, I investigated the merged manifests and found an issue. The build plugin ignored the numbers in the module name (feature1) so both features ended up having the same name. This caused a bunch of issues including the ActivityNotFound error. Renaming the feature1 module to featureOne resolved the issue.
`
<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>
`I created a sample project and shared the debug .apk file via google drive and tried to install it crashed. I could install the application from USB without a problem. I am getting following. I posted my gradle file. not sure what's going on
05-22 11:54:57.363 22469-22469/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: chin.demo.app.com.nm, PID: 22469
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{chin.demo.app.com.nm/chin.demo.app.com.nm.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "chin.demo.app.com.nm.MainActivity" on path: DexPathList[[zip file "/data/app/chin.demo.app.com.nm-1/base.apk"],nativeLibraryDirectories=[/data/app/chin.demo.app.com.nm-1/lib/arm, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "chin.demo.app.com.nm.MainActivity" on path: DexPathList[[zip file "/data/app/chin.demo.app.com.nm-1/base.apk"],nativeLibraryDirectories=[/data/app/chin.demo.app.com.nm-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Suppressed: java.lang.ClassNotFoundException: chin.demo.app.com.nm.MainActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "chin.demo.app.com.nm"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
`
Try this command in your CMD/Terminal to build apk : gradlew assembleDebug
Generate apk file using AndroidStudio
BUILD -> Build APK
OR
// Enabling multidex support.
multiDexEnabled true
OR
Right click on your project and select Properties.
Select Java Build Path from the menu on the left.
Select the Order and Export tab.
From the list make sure the libraries or external jars you added to your project are checked.
Finally, clean your project & run.
Hope it works.
when i run the app from android studio it runs fine in simulator and device.
but when i share the debug / release version of apk it got crashed when user taps on a app icon.
following the error that i can see in logs
03-11 09:16:12.654 25384-25384/com.microtechnicianapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.microtechnicianapp, PID: 25384
java.lang.RuntimeException: Unable to instantiate application com.microtechnicianapp.App: java.lang.ClassNotFoundException: Didn't find class "com.microtechnicianapp.App" on path: DexPathList[[zip file "/data/app/com.microtechnicianapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.microtechnicianapp-1/lib/x86, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:563)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4491)
at android.app.ActivityThread.access$1500(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.microtechnicianapp.App" on path: DexPathList[[zip file "/data/app/com.microtechnicianapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.microtechnicianapp-1/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newApplication(Instrumentation.java:979)
at android.app.LoadedApk.makeApplication(LoadedApk.java:558)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4491)
at android.app.ActivityThread.access$1500(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Suppressed: java.lang.ClassNotFoundException: com.microtechnicianapp.App
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
have read lot of threads but nothing works for me since morning.
have tried lot of things in gradle
apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' apply plugin: 'realm-android' android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.microtechnicianapp"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries false
} } repositories {
maven {
url "http://dl.bintray.com/lukaville/maven"
} }
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:design:25.0.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.bluelinelabs:logansquare:1.3.6'
compile 'com.github.aurae.retrofit2:converter-logansquare:1.4.1'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.google.firebase:firebase-messaging:9.8.0'
compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.google.android.gms:play-services-location:9.8.0'
compile 'com.github.gcacace:signature-pad:1.2.0'
compile 'com.github.davidpizarro:autolabelui:1.0.1'
compile 'com.nbsp:library:1.1'
compile 'com.journeyapps:zxing-android-embedded:3.2.0#aar'
compile 'com.google.zxing:core:3.2.1'
testCompile 'junit:junit:4.12'
apt 'com.bluelinelabs:logansquare-compiler:1.3.6'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'com.mikhaellopez:circularprogressbar:1.1.1'
compile 'com.android.support:multidex:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
I am using android studio 2.3 hence gradle version is gradle-3.3-all.zip
I faced the same issue today, I have currently downgraded my gradle version and the generated debug apk works just fine, Feel like it might be an issue with the gradle version, will Update on this answer if i find with the actual issue.
But currently downgrading gradle from 2.3.0 to 2.2.0 seems to fix the issue.
I had the same crash with the debug apk of one of my apps. The release version (signed with release key) worked.
My app uses multidex.
I ended up disabling Instant Run in Android Studio (File -> Settings -> Build -> Instant Run) and after a rebuild the debug apk worked as well!
Found this solution here:
https://codentrick.com/cant-run-app-on-device-when-it-installed-from-debug-apk-file/