Unable to instantiate activity ComponentInfo Android Studio 2.3.2 - android

`
<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.

Related

java.lang.ClassNotFoundException Android

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.

Unfortunately Application has stopped while launching google maps Activity

I am trying to create an application using google app activity .I have just followed the steps to create a google map application using Google maps activity and not added any extra code. The application gets crashed while launching it.I have given my manifests file, builde.gradle(app) and logcat below.
Here is my Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ranjit.getlocation">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyDd-cGnR0SwDXXDRQPqnTDpBTQ" />
<activity
android:name=".MapsActivity"
android:label="#string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
below is the build.gradle(app) file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.ranjit.getlocation"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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.1.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services:10.0.1'
testCompile 'junit:junit:4.12'
}
logcat of the application is below
08-12 10:50:02.947 15439-15439/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ranjit.getlocation, PID: 15439
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.example.ranjit.getlocation-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.ranjit.getlocation-1, /vendor/lib, /system/lib, /system/lib/arm]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5029)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4621)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4561)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.example.ranjit.getlocation-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.ranjit.getlocation-1, /vendor/lib, /system/lib, /system/lib/arm]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:5014)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4621) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4561) 
at android.app.ActivityThread.access$1500(ActivityThread.java:139) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:149) 
at android.app.ActivityThread.main(ActivityThread.java:5257) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
at dalvik.system.NativeStart.main(Native Method) 
You have to include multiDex in your application. In your manifest, you have not included the MulitiDexApplication.
ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList
Add this to your dependencies.
compile 'com.android.support:multidex:1.0.1'
In your Gradle add multiDexEnabled true.
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true // add this line
}
...
}
In your manifest add multiDex application class.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
Avoid including complete play service (compile 'com.google.android.gms:play-services:10.0.1') library. instead, use particular library you need.
Inclued this dependency for map.
com.google.android.gms:play-services-maps:11.0.4

Firebase quick start throws NoClassDefFoundError

I added the app to Firebase console and added google json file to app folder.
Then when I try to launch the app it crashes with the following message.
Thanks in Advance.
Error:
07-27 13:18:21.000 26362-26362/? E/AndroidRuntime: FATAL EXCEPTION:
main
Process: com.google.samples.quickstart.config, PID: 26362
java.lang.NoClassDefFoundError: Failed resolution of:
Lcom/google/android/gms/R$string;
at com.google.android.gms.common.internal.zzby.(Unknown Source)
at com.google.firebase.FirebaseOptions.fromResource(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown
Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown
Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5855)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5447)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5386)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.google.android.gms.R$string" on path: DexPathList[[zip file
"/data/app/com.google.samples.quickstart.config-1/base.apk", zip file
"/data/app/com.google.samples.quickstart.config-1/split_lib_dependencies_apk.apk"],nativeLibraryDirectories=[/data/app/com.google.samples.quickstart.config-1/lib/arm64,
/system/lib64, /vendor/lib64]]
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.gms.common.internal.zzby.(Unknown Source) 
at com.google.firebase.FirebaseOptions.fromResource(Unknown Source) 
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source) 
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown
Source) 
at android.content.ContentProvider.attachInfo(ContentProvider.java:1751) 
at android.content.ContentProvider.attachInfo(ContentProvider.java:1726) 
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown
Source) 
at android.app.ActivityThread.installProvider(ActivityThread.java:5855) 
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5447) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5386) 
at android.app.ActivityThread.-wrap2(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6121) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Gradle
apply plugin: 'com.android.application'
check.dependsOn 'assembleDebugAndroidTest'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.google.samples.quickstart.config"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:25.4.0'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.google.firebase:firebase-config:11.0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:1.0.0'
compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.samples.quickstart.config" >
<application
android:allowBackup="true"
android:name="android.support.multidex.MultiDexApplication"
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>
</application>
</manifest>
It works for me in Android Studio 3 Beta 5, but not in Android Studio 3 and preview 3.1
Try to clean and rebuild your project. Then start it without instant run.
I solved this issue by first adding multidex and then clean the project and rebuilding it.

Class not found using the boot class loader; no stack trace available

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"

Android Runtime Exception: Didn't find class on path: DexPathList

I downloaded this code from GitHub to see if I can customize it to work for a project I'm working on. I'm down to what I hope is my last issue but I'm completely stuck on this error. I can build and run the application but it crashes on launch.
I've gone through many similar questions here and I've made changes based on solutions but they don't seem to work for me. I'm a newbie at this and any help would be greatly appreciated. Please...anybody. :)
I'm using Android Studio.
Here's my build.gradle file. I enabled MultiDex and added support for legacy libraries. These were both suggestions in other solutions.
import java.util.regex.Pattern
//apply plugin: 'android'
apply plugin: 'com.android.application'
buildscript {
repositories {
//mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
ext.multiarch=false
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
for (subproject in getProjectList()) {
compile project(subproject)
}
compile 'com.android.support:multidex:1.0.1'
}
android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
useLibrary 'org.apache.http.legacy'
}
defaultConfig {
versionCode Integer.parseInt("" + getVersionCodeFromManifest() + "0")
//Enabling Multidex Support
multiDexEnabled true
compileSdkVersion 23
buildToolsVersion "23.0.1"
}
if (multiarch || System.env.BUILD_MULTIPLE_APKS) {
productFlavors {
armv7 {
versionCode defaultConfig.versionCode + 2
ndk {
abiFilters "armeabi-v7a", ""
}
}
x86 {
versionCode defaultConfig.versionCode + 4
ndk {
abiFilters "x86", ""
}
}
all {
ndk {
abiFilters "all", ""
}
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.12'
}
def getVersionCodeFromManifest() {
def manifestFile = file(android.sourceSets.main.manifest.srcFile)
def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
def matcher = pattern.matcher(manifestFile.getText())
matcher.find()
return Integer.parseInt(matcher.group(1))
}
def getProjectList() {
def manifestFile = file("project.properties")
def pattern = Pattern.compile("android.library.reference.(\\d+)\\s*=\\s*(.*)")
def matcher = pattern.matcher(manifestFile.getText())
def projects = []
while (matcher.find()) {
projects.add(":" + matcher.group(2).replace("/",":"))
}
return projects
}
Here's my Android Manifest file -
<?xml version='1.0' encoding='utf-8'?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ford.fordcomplince"
android:hardwareAccelerated="true"
android:versionCode="1"
android:versionName="0.1.0">
<!--
xmlns:android="http://schemas.android.com/tools"
xmlns:tools="http://schemas.android.com/apk/res-auto"> -->
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:hardwareAccelerated="true"
android:icon="#drawable/iicon"
android:label="#string/app_name">
<activity
android:name=".FordCompliance"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:label="#string/activity_name"
android:launchMode="singleTop"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".EnableMultiDex">
</activity>
</application>
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="23" />
</manifest>
I created a MultiDex.java file that extends MultiDexApplication
package com.ford.therightway;
/**
* Created by SK on 2/20/2017.
*/
import android.support.multidex.MultiDexApplication;
public class EnableMultiDex extends MultiDexApplication{
}
Here's my error output -
$ adb shell am start -n "com.ford.fordcomplince/com.ford.fordcomplince.FordCompliance" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 3449 on device emulator-5554
W/System: ClassLoader referenced unknown path: /data/app/com.ford.fordcomplince-1/lib/x86
I/InstantRun: Instant Run Runtime started. Android package is com.ford.fordcomplince, real application class is android.support.multidex.MultiDexApplication.
W/System: ClassLoader referenced unknown path: /data/app/com.ford.fordcomplince-1/lib/x86
I/MultiDex: VM with version 2.1.0 has multidex support
I/MultiDex: install
I/MultiDex: VM has multidex support, MultiDex support library is disabled.
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ford.fordcomplince, PID: 3449
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ford.fordcomplince/com.ford.fordcomplince.FordCompliance}: java.lang.ClassNotFoundException: Didn't find class "com.ford.fordcomplince.FordCompliance" on path: DexPathList[[zip file "/data/app/com.ford.fordcomplince-1/base.apk"],nativeLibraryDirectories=[/data/app/com.ford.fordcomplince-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 "com.ford.fordcomplince.FordCompliance" on path: DexPathList[[zip file "/data/app/com.ford.fordcomplince-1/base.apk"],nativeLibraryDirectories=[/data/app/com.ford.fordcomplince-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: Didn't find class "com.ford.fordcomplince.FordCompliance" on path: DexPathList[[dex file "/data/data/com.ford.fordcomplince/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.ford.fordcomplince/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.ford.fordcomplince/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.ford.fordcomplince/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.ford.fordcomplince/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.ford.fordcomplince/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.ford.fordcomplince/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.ford.fordcomplince/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.ford.fordcomplince/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.ford.fordcomplince/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.ford.fordcomplince/files/instant-run/dex/slice-com.android.support-multidex-1.0.1_363eddd5c2a30ea4be2abc16117d383bb67b8a0f-classes.dex"],nativeLibraryDirectories=[/data/app/com.ford.fordcomplince-1/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
at com.android.tools.fd.runtime.IncrementalClassLoader.findClass(IncrementalClassLoader.java:62)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Suppressed: java.lang.ClassNotFoundException: com.ford.fordcomplince.FordCompliance
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
I/Process: Sending signal. PID: 3449 SIG: 9
Application terminated.
you can disable android studio instant run feature to see if error still appear.instant run may cause strange issue

Categories

Resources