Android ClassNotFoundException: Didn't find class on path - android

I can't find the solution of this error. Can you please give the permanent solution? I have no idea how to solve it.
01-04 11:06:42.302: E/AndroidRuntime(1906): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{e.gochat/e.gochat.gochat.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "e.gochat.gochat.MainActivity" on path: DexPathList[[zip file "/data/app/e.gochat-1.apk"],nativeLibraryDirectories=[/data/app-lib/e.gochat-1, /vendor/lib, /system/lib]]
01-04 11:06:42.302: E/AndroidRuntime(1906): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2102)
01-04 11:06:42.302: E/AndroidRuntime(1906): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
01-04 11:06:42.302: E/AndroidRuntime(1906): at android.app.ActivityThread.access$700(ActivityThread.java:135)
01-04 11:06:42.302: E/AndroidRuntime(1906): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
01-04 11:06:42.302: E/AndroidRuntime(1906): at android.os.Handler.dispatchMessage(Handler.java:102)
01-04 11:06:42.302: E/AndroidRuntime(1906): at android.os.Looper.loop(Looper.java:137)
01-04 11:06:42.302: E/AndroidRuntime(1906): at android.app.ActivityThread.main(ActivityThread.java:4998)
01-04 11:06:42.302: E/AndroidRuntime(1906): at java.lang.reflect.Method.invokeNative(Native Method)
01-04 11:06:42.302: E/AndroidRuntime(1906): at java.lang.reflect.Method.invoke(Method.java:515)
01-04 11:06:42.302: E/AndroidRuntime(1906): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
01-04 11:06:42.302: E/AndroidRuntime(1906): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
01-04 11:06:42.302: E/AndroidRuntime(1906): at dalvik.system.NativeStart.main(Native Method)
01-04 11:06:42.302: E/AndroidRuntime(1906): Caused by: java.lang.ClassNotFoundException: Didn't find class "e.gochat.gochat.MainActivity" on path: DexPathList[[zip file "/data/app/e.gochat-1.apk"],nativeLibraryDirectories=[/data/app-lib/e.gochat-1, /vendor/lib, /system/lib]]
01-04 11:06:42.302: E/AndroidRuntime(1906): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
01-04 11:06:42.302: E/AndroidRuntime(1906): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
01-04 11:06:42.302: E/AndroidRuntime(1906): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
01-04 11:06:42.302: E/AndroidRuntime(1906): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
01-04 11:06:42.302: E/AndroidRuntime(1906): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2093)
01-04 11:06:42.302: E/AndroidRuntime(1906): ... 11 more
01-04 11:07:06.772: I/Process(1906): Sending signal. PID: 1906 SIG: 9
This is my app Manifest XML
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="e.gochat"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
<permission
android:name="e.gochat.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="e.gochat.permission.C2D_MESSAGE" />
<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" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
android:name="e.gochat.Common"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="e.gochat.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="e.gochat.ChatActivity"
/>
<activity
android:name="e.gochat.SettingsActivity"
android:label="#string/title_activity_settings" />
<receiver
android:name="e.gochat.client.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="e.gochat" />
</intent-filter>
</receiver>
<provider
android:name="e.gochat.DataProvider"
android:authorities="e.gochat.provider"
android:exported="false">
</provider>
</application>
I'm not sure what's wrong here. I've added the .jar file in the java build path. And yet I'm getting this classnotfound exception. The app loads when I import the android.app.Application

I have solved this problem by disabling the instant run option of android studio.
To disable Instant Run Goto
File -> Settings
-> Build,Execution, Deployment -> Instant Run -> Uncheck the checkbox for instant run

I don't know for sure what is your package name, but if it is e.gochat do this.
Add package="e.gochat" to manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="e.gochat"
.....
.....
>
On each activity declaration for android:name put a dot before activity name:
<activity
android:name=".MainActivity">
............
</activity>
<activity
android:name=".ChatActivity">
EDIT
After your edited I can see e.gochat is your package name.
Now you only need to remove e.gochat from each activity/provider/receiver name as I said in second part of my answer.
Android will add that for you.

Using Android Studio
After upgrading to Android Stuido 0.8.2, I had this problem. I tried a lot of things, including
Clean project
Clean project (gradle clean)
Invalidate Caches and Restart
De-qualify the Activity Name in AndroidManifest.xml (.MyActivity)
Nothing worked until I re-imported the entire project.
File -> Close Project -> Import Project... -> Choose the same project -> OK
This fixed it for me

Uninstalling the app in the device and running the project again fixed it for me.

The reason why this was affecting me was due to an incorrect path name in a layout file
<android.support.v4.app.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v4.app.view.ViewPager>
The correct absolute path of ViewPager is
android.support.v4.view.ViewPager
After correcting the path it worked. I did not have to prefix the activity name with a '.'.

For me, this was occurring on devices running < Android 5.0 because I didn't have multidex support enabled (this is, over 65k total methods incl. libs). Multidex is automatic and native on Android 5.0+ (specifically, devices using ART).

The problem was solved by removing MultiDexSupport from build.gradle file :
defaultConfig {
multiDexEnabled true // This line was causing above problem
}
Removing the MultiDexSupport solved the problem

This issue has multiple answers based on the different scenario.
I was getting the same error when using a library(.aar) in my Android Studio project.
The root cause in my case was that I missed to add a third party lib dependency in app's build.gradle file which was being used by the .aar file.
e.g:- The library(.aar) was using 'com.squareup.okhttp3:okhttp:3.4.1'. So I had to add
compile 'com.squareup.okhttp3:okhttp:3.4.1'
in the app's build.gradle. Hope it helps someone.

ANDROID STUDIO
In addittion to Kishor's answer:
The error occured on my small project when I enabled multiDexEnabled = true in the gradle defaultconfig.
Using the generated .apk file crashes on start of the app with the known error message.
For me it was solved when I built the .apk file via gradle (right side of android studio) -> "yourapp" -> Tasks- > install -> installDebug
Hope this helps someone with this strange error

I implemented a listener that was not available in the android version I was running yet and this led to the same error.
Example MainActivity:
// RecyclerView.OnScrollChangeListener is only available on API >= 23
public class MainActivity implements RecyclerView.OnScrollChangeListener
{
}
Running this activity on a device with API < 23 will result in this error as well...

If you tried other solitions and none of them work. Sometimes this error happen because some library use Java 8 features. To solve the problem, configure Android Gradle Plugin to support Java 8 by adding the following code to your build.gradle file
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

For me the issue occurred as I wasn't including the kotlin-android and kotlin-android-extensions plugins in my :app modules build.gradle.
E.g.
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
Or if you're using the Kotlin DSL
plugins {
id("com.android.application")
kotlin("android")
kotlin("android.extensions")
}

dependencies {
implementation 'androidx.appcompat:appcompat:+'
implementation 'androidx.constraintlayout:constraintlayout:+'
}
Remove this line from Gradle

Related

Didn't find class "androidx.core.content.FileProvider"

I migrated my app to AndroidX and it's crashing on launch on API level 21. My application throws this exception:
10-08 09:42:50.930 11346-11346/com.example.test E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.test, PID: 11346
java.lang.RuntimeException: Unable to get provider androidx.core.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "androidx.core.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.example.test-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.test-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5121)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4713)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4596)
at android.app.ActivityThread.access$1600(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
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:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.example.test.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.test-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:5106)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4713) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4596) 
at android.app.ActivityThread.access$1600(ActivityThread.java:169) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5487) 
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:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method)
And here is the provider definition in my AndroidManifest.xml file:
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths" />
</provider>
On the latest API level it works fine. Any suggestions would be useful, thanks in advance.
It seems that this error came from incomplete configuration of MultiDex in your app. Here you may find the similar issue and here is an article answering it.
I suggest you to check the following (extending App class helped me):
Your Application class (App.class, for instance, if you use it) should extend from MultiDexApplication class:
public class BaseApplication extends MultiDexApplication {}
or if you don't use Application class check your manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
The documentation is outdated; use androidx.multidex for androidx:
implementation "androidx.multidex:multidex:2.0.1"
AndroidManifest.xml:
<application
android:name="androidx.multidex.MultiDexApplication">
</application>
Use the Jetifier when it still uses any com.android.support libraries:
android.enableJetifier=true
The problem is your React Native android project is not in AndroidX while react-native-image-picker is in an AndroidX environment; therefore, it is missing packages from the androidx package library.
Simple fix is adding the following lines to your ./android/gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
If you have any existing RN libraries that uses old android packages, your project won't build since they will be missing once you updated your project.
A clever tool found here deals with RN libraries that uses old android packages and brings them up to date.
npm i --save-dev jetifier
npx jetify
react-native run-android
All checked out and it's working on my end. Hope this helps anyone and please do share if it does.
Source https://github.com/react-native-community/react-native-image-picker/issues/1088#issuecomment-509755692
add below ndk lib support to your project if you have used the external library -
ndk
{
abiFilters "armeabi-v7a", "x86", "x86_64", "arm64-v8a"
}
inside the default config of your app level build.gradle file
defaultConfig
{
applicationId "org.comcast.net"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk
{
abiFilters "armeabi-v7a", "x86", "x86_64", "arm64-v8a"
}
}
it has solved my problem, hopefully it will solve at your end also.

Class Extending FirebaseMessagingService not working inside Android Library

I created an Android Library to implement FCM to use in my internal projects, where I implement a class to extend FirebaseMessagingService (.services.MyFirebaseMessagingService ) and another one to extend FirebaseInstanceIdService (.services.MyFirebaseInstanceIDService).
I defined this in my AndroidManifest.xml inside the library as below:
<!-- [START firebase_service] -->
<service
android:name=".services.MyFirebaseMessagingService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- [END firebase_service] -->
<!-- [START firebase_iid_service] -->
<service android:name=".services.MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<!-- [END firebase_iid_service] -->
When I included all the library source code as a module in my App, everything worked well, but when I included only the AAR generated, I received this error when I run my application:
java.lang.RuntimeException: Unable to instantiate service com.example.lib.services.MyFirebaseMessagingService: java.lang.ClassNotFoundException: com.example.lib.services.MyFirebaseMessagingService
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2380)
at android.app.ActivityThread.access$1600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4905)
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:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.example.lib.services.MyFirebaseMessagingService
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2377)
at android.app.ActivityThread.access$1600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4905)
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:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
The service com.example.lib.services.MyFirebaseInstanceIDService works correctly.
What I need to do with AAR generated library to work?
For FCM follow this step :
1 - in main Build.gradle (not in app folder) add this line :
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
2- in app/build.gradle add this line :
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-messaging:9.8.0'
// Getting a "Could not find" error? Make sure you have
// the latest Google Repository in the Android SDK manager
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Note : "Android Support Repository" in you SDk most be updated .
Hope this help
click on Build - > Clean then install & run the app

How to solve the ClassNotFoundException of android project in eclipse?

I have a android project built with Eclipse. I can build the APK, but it crashed as the following logs:
E/AndroidRuntime(27898): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/pili/pldroid/streaming/camera/demo/CameraStreamingActivity;
E/AndroidRuntime(27898): at com.example.rtmpdemo.MainActivity$1.onClick(MainActivity.java:35)
E/AndroidRuntime(27898): at android.view.View.performClick(View.java:4757)
E/AndroidRuntime(27898): at android.view.View$PerformClick.run(View.java:19757)
E/AndroidRuntime(27898): at android.os.Handler.handleCallback(Handler.java:739)
E/AndroidRuntime(27898): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(27898): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(27898): at android.app.ActivityThread.main(ActivityThread.java:5258)
E/AndroidRuntime(27898): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(27898): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(27898): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
E/AndroidRuntime(27898): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
E/AndroidRuntime(27898): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.pili.pldroid.streaming.camera.demo.CameraStreamingActivity" on path: DexPathList[[zip file "/data/app/com.example.rtmpdemo-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.rtmpdemo-1/lib/arm, /vendor/lib, /system/lib]]
E/AndroidRuntime(27898): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(27898): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(27898): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(27898): ... 11 more
E/AndroidRuntime(27898): Suppressed: java.lang.NoClassDefFoundError: com.pili.pldroid.streaming.camera.demo.CameraStreamingActivity
E/AndroidRuntime(27898): at dalvik.system.DexFile.defineClassNative(Native Method)
E/AndroidRuntime(27898): at dalvik.system.DexFile.defineClass(DexFile.java:226)
E/AndroidRuntime(27898): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
E/AndroidRuntime(27898): at dalvik.system.DexPathList.findClass(DexPathList.java:321)
E/AndroidRuntime(27898): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
E/AndroidRuntime(27898): ... 13 more
E/AndroidRuntime(27898): Suppressed: java.lang.ClassNotFoundException: com.pili.pldroid.streaming.camera.demo.CameraStreamingActivity
E/AndroidRuntime(27898): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(27898): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(27898): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(27898): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(27898): ... 12 more
E/AndroidRuntime(27898): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
W/ActivityManager( 810): Force finishing activity com.example.rtmpdemo/.MainActivity
I have defined the CameraStreamingActivity absolutely and registered in the AndroidManifest.xml. The structure of the project like this:
./AndroidManifest.xml
./assets
./libs
./libs/android-support-v4.jar
./libs/armeabi-v7a
./libs/armeabi-v7a/libpldroid_ffmpegbridge.so
./libs/pldroid-camera-streaming-1.2.0.jar
./lint.xml
./proguard-project.txt
./project.properties
./src
./src/com
./src/com/example
./src/com/example/rtmpdemo
./src/com/example/rtmpdemo/MainActivity.java
./src/com/pili
./src/com/pili/pldroid
./src/com/pili/pldroid/streaming
./src/com/pili/pldroid/streaming/camera
./src/com/pili/pldroid/streaming/camera/demo
./src/com/pili/pldroid/streaming/camera/demo/AudioStreamingActivity.java
./src/com/pili/pldroid/streaming/camera/demo/CameraStreamingActivity.java
./src/com/pili/pldroid/streaming/camera/demo/StreamingBaseActivity.java
./src/com/pili/pldroid/streaming/camera/demo/TestActivity.java
The AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rtmpdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.rtmpdemo.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="com.pili.pldroid.streaming.camera.demo.CameraStreamingActivity" >
</activity>
<activity
android:name="com.pili.pldroid.streaming.camera.demo.AudioStreamingActivity"
android:label="#string/title_activity_audio_streaming" >
</activity>
<activity android:name="com.pili.pldroid.streaming.camera.demo.TestActivity" >
</activity>
</application>
</manifest>
HOWEVER, it works fine after i import the project into Android Studio.
The import-summary.txt as following:
ECLIPSE ANDROID PROJECT IMPORT SUMMARY
======================================
Ignored Files:
--------------
The following files were *not* copied into the new Gradle project; you
should evaluate whether these are still needed in your project and if
so manually move them:
* .DS_Store
* ic_launcher-web.png
* proguard-project.txt
Replaced Jars with Dependencies:
--------------------------------
The importer recognized the following .jar files as third party
libraries and replaced them with Gradle dependencies instead. This has
the advantage that more explicit version information is known, and the
libraries can be updated automatically. However, it is possible that
the .jar file in your project was of an older version than the
dependency we picked, which could render the project not compileable.
You can disable the jar replacement in the import wizard and try again:
android-support-v4.jar => com.android.support:support-v4:19.1.0
Moved Files:
------------
Android Gradle projects use a different directory structure than ADT
Eclipse projects. Here's how the projects were restructured:
* AndroidManifest.xml => app/src/main/AndroidManifest.xml
* assets/ => app/src/main/assets/
* libs/armeabi-v7a/libpldroid_ffmpegbridge.so => app/src/main/jniLibs/armeabi-v7a/libpldroid_ffmpegbridge.so
* libs/pldroid-camera-streaming-1.2.0.jar => app/libs/pldroid-camera-streaming-1.2.0.jar
* lint.xml => app/lint.xml
* res/ => app/src/main/res/
* src/ => app/src/main/java/
Next Steps:
-----------
You can now build the project. The Gradle project needs network
connectivity to download dependencies.
Bugs:
-----
If for some reason your project does not build, and you determine that
it is due to a bug or limitation of the Eclipse to Gradle importer,
please file a bug at http://b.android.com with category
Component-Tools.
(This import summary is for your information only, and can be deleted
after import once you are satisfied with the results.)
What did i miss?
Thanks.
Actually, your code don't have any problem. And this is the runtime error.
I sure that root cause is coming from libs which you import by wrong way.
"./libs/pldroid-camera-streaming-1.2.0.jar"
Try to remove this lib and import again by other way such as:
way 1: Java build path-> Libraries -> Add External JARS..
way 2: manual copy this lib directly to ".libs/" folder

java.lang.ClassNotFoundException when install app from APK [duplicate]

This question already has answers here:
Android ClassNotFoundException: Didn't find class on path
(37 answers)
Closed 8 years ago.
The error I describe below, occurs when:
Install the app on a device directly from the APK.
Download the app by Play Store
The error don´t occurs when:
Install apk through Eclipse pressing the 'run' button
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{my.package/my.package.MainActivity}:
java.lang.ClassNotFoundException: my.package.MainActivity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1998)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2099)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4929)
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:798)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:565)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: my.package.MainActivity
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1056)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1989)
... 11 more
To export the APk I do as always, from "Use the Export Wizard to export and sign an APK"
Any idea because it occurs from the APK but not directly from eclipse?
The above error is generated by me. But reports of users are somewhat different:
User1:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{my.package/my.package.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class
"my.package.MainActivity" on path: DexPathList[dexElements=[zip file
"/data/app/my.package-1.apk"],nativeLibraryDirectories=[/data/app-lib/my.package-1,
/vendor/lib, /system/lib]]
User2:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{my.package/my.package.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class
"my.package.MainActivity" on path: DexPathList[[zip file
"/data/app/my.package-1.apk"],nativeLibraryDirectories=[/data/app-lib/my.package-1,
/vendor/lib, /system/lib]]
Manifest:
<?xml version="1.0" encoding="utf-8"?> <manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="my.package"
android:versionCode="12"
android:versionName="2.3" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/motion"
android:label="#string/app_name"
android:largeHeap="true"
android:theme="#style/Theme.AppCompat.Light" >
<activity
android:name="my.package.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="my.package.AlarmsListActivity"
android:theme="#style/dialogTheme"/>
<activity android:name="my.package.ImagenesActivity"/>
<activity android:name="my.package.EndActivity" />
</application>
</manifest>
I use the following libraries in MainActivity
This is your error:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{my.package/my.package.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "my.package.MainActivity" on path: DexPathList[dexElements=[zip file "/data/app/my.package-1.apk"],nativeLibraryDirectories=[/data/app-lib/my.package-1, /vendor/lib, /system/lib]]
Solution:
You have added library project as a reference to your project and also may be you have added jar files for ChartView and support-v7 in your libs folder and also as a Add External Jars. So you have to enable both checkboxes for android-support-v7.jar file and for chartview jar file in order and export menu.
The path for it is,
Project - Right Click - Properties - Java Build Path - Order and Export Menu.
Finally you need to clean and run your project.

Using Android Emulator (eclipse) fails to start the tic-tac-toe example

I am trying to test the tic-tac-toe in eclipse. It compiles and deploys to emulator device (AVD) but no matter what version of Android I use, the application deployed says: Application Stopped. Close it. Is there any specific setting I should follow?
Note: I already setup the Eclipse environment, add libraries, etc.
Thanks!
Here is the log error:
01-16 01:07:35.994: E/AndroidRuntime(883): FATAL EXCEPTION: main
01-16 01:07:35.994: E/AndroidRuntime(883): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.google.cast.samples.tictactoe/com.google.cast.samples.tictactoe.GameActivity}: java.lang.ClassNotFoundException: Didn't find class "com.google.cast.samples.tictactoe.GameActivity" on path: DexPathList[[zip file "/data/app/com.google.cast.samples.tictactoe-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.google.cast.samples.tictactoe-1, /system/lib]]
01-16 01:07:35.994: E/AndroidRuntime(883): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
01-16 01:07:35.994: E/AndroidRuntime(883): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
01-16 01:07:35.994: E/AndroidRuntime(883): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-16 01:07:35.994: E/AndroidRuntime(883): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.cast.samples.tictactoe.GameActivity" on path: DexPathList[[zip file "/data/app/com.google.cast.samples.tictactoe-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.google.cast.samples.tictactoe-1, /system/lib]]
01-16 01:07:35.994: E/AndroidRuntime(883): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
Thanks Ali. Here is the manifest, but I see there is a match of class and activity.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.cast.samples.tictactoe"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature
android:name="android.hardware.wifi"
android:required="true" >
</uses-feature>
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat" >
<activity
android:name=".GameActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Exception states that it didn't find your GameActivity class. Check your Manifest and see if the name given there as the launcher activity (GameActivity) matches with the class that you have in your package, check the package names, etc. The exception has nothing to do (at least the piece that you have shown) with Cast.
Thanks for all the help. I solved by silly configuration. I created a libs folder and copied under GoogleCastSDKAndroid.jar (marked as Private Library). Compiled and it worked perfect!
Now, I just learned the casting function can't work because AVD runs a different IP address (in my case registered a 10.0.2.15) than my wifi segment (192.168.1.x). Therefore, the AVD can't see a chrome device.
I hope this last conclusion helps other people. The first was a mistake of configuration.

Categories

Resources