program story

ADT 업데이트 후 ClassNotFoundException

inputbox 2020. 12. 7. 08:07
반응형

ADT 업데이트 후 ClassNotFoundException


최근에 Android SDK 및 Eclipse ADT 플러그인을 최신 버전으로 업데이트했습니다. 이제 기존 Android 프로젝트를 실행하려고하면 LogCat에 ClassNotFoundException.

새 장치를 만들려고했지만 문제가 여전히 존재합니다.

명백한

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

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

<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:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.myapp.MainActivity"
        android:label="@string/app_name"
        android:windowSoftInputMode="stateHidden" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

LogCat

05-17 13:09:56.357: E/AndroidRuntime(969): FATAL EXCEPTION: main
05-17 13:09:56.357: E/AndroidRuntime(969): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.myapp/com.example.myapp.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.myapp.MainActivity" on path: /data/app/com.example.myapp-1.apk
05-17 13:09:56.357: E/AndroidRuntime(969):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
05-17 13:09:56.357: E/AndroidRuntime(969):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-17 13:09:56.357: E/AndroidRuntime(969):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-17 13:09:56.357: E/AndroidRuntime(969):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-17 13:09:56.357: E/AndroidRuntime(969):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-17 13:09:56.357: E/AndroidRuntime(969):  at android.os.Looper.loop(Looper.java:137)
05-17 13:09:56.357: E/AndroidRuntime(969):  at android.app.ActivityThread.main(ActivityThread.java:5041)
05-17 13:09:56.357: E/AndroidRuntime(969):  at java.lang.reflect.Method.invokeNative(Native Method)
05-17 13:09:56.357: E/AndroidRuntime(969):  at java.lang.reflect.Method.invoke(Method.java:511)
05-17 13:09:56.357: E/AndroidRuntime(969):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-17 13:09:56.357: E/AndroidRuntime(969):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-17 13:09:56.357: E/AndroidRuntime(969):  at dalvik.system.NativeStart.main(Native Method)
05-17 13:09:56.357: E/AndroidRuntime(969): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.myapp.MainActivity" on path: /data/app/com.example.myapp-1.apk
05-17 13:09:56.357: E/AndroidRuntime(969):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
05-17 13:09:56.357: E/AndroidRuntime(969):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-17 13:09:56.357: E/AndroidRuntime(969):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-17 13:09:56.357: E/AndroidRuntime(969):  at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
05-17 13:09:56.357: E/AndroidRuntime(969):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
05-17 13:09:56.357: E/AndroidRuntime(969):  ... 11 more

새 APK 파일은 myapp-1.apk 이고 일반적으로 myapp.apk 라는 것을 알았습니다 . 누군가 해결 방법을 말해 줄 수 있습니까?


가는 시도 프로젝트 -> 속성 -> 자바 빌드 경로 -> 주문 및 내보내기 및 확인 안드로이드 개인 라이브러리가 선택되어 프로젝트에 대한 다른 모든 라이브러리 프로젝트에 사용된다. 나중에 모든 프로젝트를 정리하고 어떤 일이 발생하는지 확인하십시오.


I know I'm very late to post a reply here. The workaround mentioned by Krauxe didn't help me. My project has two library projects and two jars. I found a solution posted by "laaptu" in the page Libraries do not get added to APK anymore after upgrade to ADT 22.


I have the Eclipse ADT bundle and additional to the @Krauxe's answer, updating the Eclipse .project file as below worked for me:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>RedbeaconPro</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.ApkBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

If you are using Maven plugin in your project as well, "Maven -> Maven Update..." may cause the same problem that ClassNotFoundException. As you know, the default classes output folder should be /bin/classes which is specified in .classpath file and Eclipse Build Path. But once you do "Maven->Maven Update...", the output folder would be set as "target/classes". You can find it(output="target/classes") in your .classpath file.

.classpath file:

...    
<classpath>
            <classpathentry kind="src" path="gen"/>
            <classpathentry kind="src" output="target/classes" path="src/main/java">
...

How to resolve this problem, please explicitly specify the classes output folder as "bin/classes" in pom.xml file.

pom.xml file:

...
<build>
            <sourceDirectory>src/main/java</sourceDirectory>
            <outputDirectory>bin/classes</outputDirectory>
...

참고URL : https://stackoverflow.com/questions/16610190/classnotfoundexception-after-adt-update

반응형