code

Android ClassNotFoundException : 경로에서 클래스를 찾지 못했습니다.

codestyles 2020. 8. 30. 08:39
반응형

Android ClassNotFoundException : 경로에서 클래스를 찾지 못했습니다.


10-22 15:29:40.897: E/AndroidRuntime(2561): FATAL EXCEPTION: main
10-22 15:29:40.897: E/AndroidRuntime(2561): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.gvg.simid/com.gvg.simid.Login}: java.lang.ClassNotFoundException: Didn't find class "com.gvg.simid.Login" on path: DexPathList[[zip file "/data/app/com.gvg.simid-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.gvg.simid-1, /vendor/lib, /system/lib]]
10-22 15:29:40.897: E/AndroidRuntime(2561):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at android.os.Looper.loop(Looper.java:137)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at android.app.ActivityThread.main(ActivityThread.java:5103)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at java.lang.reflect.Method.invokeNative(Native Method)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at java.lang.reflect.Method.invoke(Method.java:525)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at dalvik.system.NativeStart.main(Native Method)
10-22 15:29:40.897: E/AndroidRuntime(2561): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.gvg.simid.Login" on path: DexPathList[[zip file "/data/app/com.gvg.simid-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.gvg.simid-1, /vendor/lib, /system/lib]]
10-22 15:29:40.897: E/AndroidRuntime(2561):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
10-22 15:29:40.897: E/AndroidRuntime(2561):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
10-22 15:29:40.897: E/AndroidRuntime(2561):     ... 11 more

매니페스트에 올바르게 나열되어 있기 때문에 원인이 무엇인지 잘 모르겠습니다.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.gvg.simid"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_LOGS" />
    <uses-permission android:name="android.permission.READ_OWNER_DATA" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_OWNER_DATA" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <uses-feature android:name="android.hardware.usb.host" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.gvg.simid.Login"
            android:label="@string/app_name" 
            android:screenOrientation="landscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

또한 경로를 빌드하기 위해 "Android Private Libraries"를 추가하고 "Order and Export"맨 위로 이동했지만 여전히 동일한 오류가 발생했습니다.

편집 : 프로젝트를 완전히 다시 빌드했지만 오류를 재현 할 수 없습니다. 원인이 무엇인지 확실하지 않습니다.


내 프로젝트에 동일한 문제가있었습니다. 내 프로젝트와 내 프로젝트에 추가 한 라이브러리 프로젝트 간의 Android 지원 라이브러리 버전 충돌로 인해 발생했습니다. 포함 된 프로젝트와 라이브러리 프로젝트에 동일한 버전의 Android 지원 라이브러리를 넣고 빌드를 정리합니다 . 모든 것이 작동합니다 ...


이 다음 방법이 저에게 효과적이었습니다. 를 마우스 오른쪽 버튼으로 클릭 project하고 properties. "속성"패널이 열립니다. 왼쪽 메뉴에서 Java Build Path-> 로 이동합니다 Order and Export. 아래 목록에서 옆의 확인란을 선택 취소합니다 "Android Dependencies". 마지막으로 clean your project실행하십시오.

작동하기를 바랍니다.


Android Studio 에서이 문제를 겪고 계신 분들에게는 병합 후에도 동일한 문제가 발생했으며 어떤 이유로 든 지속 clean되고 invalidate cash/restart작업이 나를 미치게 만들었습니다.

결과적으로 명령 줄에서 gradle build를 한 번 실행하여 해결할 수 있습니다. 프로젝트 디렉토리에서 다음 n을 실행하기 만하면됩니다.

./gradlew assemble clean
./gradlew assemble

내가 겪어야했던 시간 낭비와 좌절을 누군가에게 구할 수 있기를 바랍니다.


Eclipse를 사용하는 경우 Project-> Clean을 시도하십시오.


나는 같은 문제가 있었고 이것은 나를 위해 일했습니다.

1) 상대 경로 대신 메인 페스트의 전체 활동 경로.

2) 'build'폴더를 삭제하고 프로젝트를 정리합니다.


이것은 우리가 APP의 빌드 경로를 변경하면 발생하며, 이는 라이브러리 또는 .jar 파일 추가 또는 제거 또는 변경의 경우에 발생할 수 있습니다. 가장 좋은 해결책은 Eclipse다시 시작하는 것입니다.


Android Studio 2.0 이상에서 새로운 Instant Run 기능을 사용하는 동안이 오류가 발생하면 이것은 일종의 버그입니다.
이 문제를 해결하려면 앱이 중지되지 않은 경우 Device / Emulator에서 수동으로 중지 한 다음 Android Studio에서 BuildRebuild Project.
그런 다음 실행 단추 또는 Shift + F10을 클릭하십시오.


multidex를 사용하는 사람은 이것을 작성하십시오.

build.gradle 내부

apply plugin: 'com.android.application'

android {
 defaultConfig {
      multiDexEnabled true
  }
 dexOptions {
        javaMaxHeapSize "4g"
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:multidex:1.0.1'
}

EnableMultiDex아래와 같은 수업을 작성 하세요

import android.content.Context;
import android.support.multidex.MultiDexApplication;

public class EnableMultiDex extends MultiDexApplication {
    private static EnableMultiDex enableMultiDex;
    public static Context context;

    public EnableMultiDex(){
        enableMultiDex=this;
    }

    public static EnableMultiDex getEnableMultiDexApp() {
        return enableMultiDex;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();

    }
}

and in AndroidManifest.xml write this className inside Application tag

 <application
    android:name="YourPakageName.EnableMultiDex"
    android:hardwareAccelerated="true"
    android:icon="@drawable/wowio_launch_logo"
    android:label="@string/app_name"
    android:largeHeap="true"
    tools:node="replace">

If you are using Multidex on Android 4.4 and prior, your issue might be that your activity class is located in the second dex file and therefore not found by the android system.

To keep your activity class in the main dex file, see this page:

https://developer.android.com/studio/build/multidex.html#keep


To find which classes are located in a dex file use Android Studio.

Simply drag n drop your apk into Android Studio. You should be able to see your dex files in the apk explorer.

Then select the dex file to see what classes are inside.


another alternative is dexdump:

You can check the content of your dex files contained in your apk by using the command dexdump which can be found in

android-sdk/build-tools/27.0.3/dexdump

For windows users see this tool I made to ease the process


In my case it was proguard minification process that removed some important classes from my production apk.

The solution was to edit the proguard-rules.pro file and add the following:

-keep class com.someimportant3rdpartypackage.** { *; }

1) Create libs folder under project root
2) Copy and paste the jar file into it
3) Configure the build path (Add jar)
4) Clean and run

cheers :-)


Believe me or not... I tried out almost each answer I had found here on stackoverflow. Nothing would help, until I just restarted the machine. My Android Studio works on Ubuntu 16.04 LTS.


I faced this error once when I defined a class that extended a view but referred to this custom view in the layout file with the wrong name. Instead of <com.example.customview/>, I had included <com.customview/> in the XML layout file.


I met the same problem and I noticed the sample code was put under directory "java" instead of directory "src". After moving the code to src, the problem was solved.

Also make sure the app directory is split into multiple folders. e.g. /main/com/site/appname/ not /main/com.site.appname/

Hope it works~


If you added a new Library Project as module to your Android project and you're using Kotlin in your library do not forget to add

apply plugin: 'kotlin-android'

to top of your module's gradle file. Android Studio does not add this line when you created new module and this may waste your hours like me.


I had this issue recently and I am using Android Studio 0.8.4

The problem was the fact that I decided to rename an XML menu layout file that was called main.xml.

Right click on it and chose Refactor --> Rename. Before renaming it, be sure uncheck "Search in comments and strings" and pressed Refactor.

Because my file was originally named 'main', it renamed critical paths in the app.iml and build.gradle, mainly the java.srcDirs in the build.gradle, since the path is defined as 'src/main/java'.

I hope this helps anyone that may be experiencing this issue.


I had this problem after upgrading from version 18. After the upgrade I had the following: Project Build Target was 5.01, targetSDKVersion=21

But: Build Tools were still from Android 4.3.1 (18) What I noticed was that those apps that were deriving their activities from ActionBarActivity crashed with the above error those that did not still ran.

So the simple fix was to use the latest Android SDK Build Tools 21.1.2 instead of only those of Android SDK Build Tools 18, which seems somehow the default.

So the culprit seems the Appcompat library, which I use for Actionbar backward compability.

And a by the way: using the appcompat library I had to set/fix: $SDKInstallDIR$\Android\android-sdk\extras\android\support\v7\appcompat\project.properties target=android-21 (which was recommended in some other useful post and which has a value of 19 by default))


I had the same issue on Windows. I had renamed the path to the project to something containing a space.

Make sure the path to your project does not contain a space.


I faced the same problem and solved it by doing the following:

From the build menu select

1- clean Project.

2- Build APK.


Solution mentioned here --> Multidex Issue solution worked for me. Below is what needs to be added to Application context :

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

I face the same problem , and after a lot of work and search , I figured out the solution : I just cleaned the project then build the apk. -Build->Clean Project -Build-> Build APK(s) I hope it is useful.....


I had this issue, raised by several causes, but i see this in your stacktrace "**Unable to instantiate activity ComponentInfo{...}: java.lang.ClassNotFoundException: Didn't find class "..." on path: DexPathList[[**", I found a diference in my .classpath before it stop working.

 <?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

I've ADDED the line:

<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>

this is the final version:

  <?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

Now it works! =)


I had the same exact issue. As @weiweia suggested, move the code from the java directory to src worked for me. I also removed the Android Dependencies from Project --> Properties --> Java Build Path --> Order and Export, and made sure only to include Library Projects in the Android screen.


I had this problem for quite a while, and like everybody else the answers above didn't apply to my project.

In my project I had linked up a project to my project and it was throwing ClassDefNotFoundError every time some code for the other project was executed.

So this was my solution. I went to project properties of my project and Java Build Path. Pressed the "Source"-tab and "link source" from src-folder of the other project to my own project and named a new folder "core-src".

Hopes this solution helps someone


I had the same issue. I am using Xamarin.Android.

The problem in my case was that I changed the versionCode and versionName.

I had no problem when I had them set like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="pac.ka.ge" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">

The issue appeared when I changed it to this (versionCode 2 and versionName 0.0.1):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package=" pac.ka.ge " android:versionCode="2" android:versionName="0.0.1" android:installLocation="auto">

I fixed the issue by changing to versionCode 2 and versionName 1.0.0.1, like so:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package=" pac.ka.ge " android:versionCode="2" android:versionName="1.0.0.1" android:installLocation="auto">

I am unsure why this was a problem, maybe Android doesn't like a lower versionName with a higher versionCode?

I found the following on http://developer.android.com/guide/topics/manifest/manifest-element.html#vname

android:versionCode An internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName attribute. The value must be set as an integer, such as "100". You can define it however you want, as long as each successive version has a higher number. For example, it could be a build number. Or you could translate a version number in "x.y" format to an integer by encoding the "x" and "y" separately in the lower and upper 16 bits. Or you could simply increase the number by one each time a new version is released.

android:versionName The version number shown to users. This attribute can be set as a raw string or as a reference to a string resource. The string has no other purpose than to be displayed to users. The versionCode attribute holds the significant version number used internally.


Just in case anybody faces the same problem as me and no suggest answer here helps.

For me the cause was, that the Android studio refactor is buggy. I moved an innerclass outside of a class, which was a View and therefore also had a xml, where the direct path was set. This path will not get refactored by studio! And no error will be thrown.

Hope this helps anybody. Cheers.


In our case we wanted to compile Vagrant version and had same error. We fixed it by clean project and rebuild project in Build menu


I just restarted the device and ran the app. It worked without any issues. Hope this helps someone :)


I found this error in Android Studio when i tried do debug in a device with API 23, so i checked the Android Studio and i noticed that i didnt had instaled this API 23 version. After install, i solved the problem.


I had this problem several times and often I didn't do something obviously wrong with dependencies.

It's always a good idea to check if this 'not found' class is present in the final apk. If it is, like it happened in my cases, the problem usually is:

It's not that given class is not found, but it cannot be loaded because its super class is missing.

Check if class that you extend is available and then try to fix your build script or dependencies accordingly.

참고URL : https://stackoverflow.com/questions/19523167/android-classnotfoundexception-didnt-find-class-on-path

반응형