所以我导入了一个android项目,在我终于完成时挣扎了一段时间后,我编译了这个应用程序并且它崩溃了。
这是 logcat 文件:
07-16 23:02:23.700: E/AndroidRuntime(23092): FATAL EXCEPTION: main
07-16 23:02:23.700: E/AndroidRuntime(23092): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{si.dvanadva.evanturist/si.dvanadva.evanturist.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "si.dvanadva.evanturist.MainActivity" on path: /data/app/si.dvanadva.evanturist-2.apk
07-16 23:02:23.700: E/AndroidRuntime(23092): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
07-16 23:02:23.700: E/AndroidRuntime(23092): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-16 23:02:23.700: E/AndroidRuntime(23092): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-16 23:02:23.700: E/AndroidRuntime(23092): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-16 23:02:23.700: E/AndroidRuntime(23092): at android.os.Handler.dispatchMessage(Handler.java:99)
07-16 23:02:23.700: E/AndroidRuntime(23092): at android.os.Looper.loop(Looper.java:137)
07-16 23:02:23.700: E/AndroidRuntime(23092): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-16 23:02:23.700: E/AndroidRuntime(23092): at java.lang.reflect.Method.invokeNative(Native Method)
07-16 23:02:23.700: E/AndroidRuntime(23092): at java.lang.reflect.Method.invoke(Method.java:511)
07-16 23:02:23.700: E/AndroidRuntime(23092): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-16 23:02:23.700: E/AndroidRuntime(23092): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-16 23:02:23.700: E/AndroidRuntime(23092): at dalvik.system.NativeStart.main(Native Method)
07-16 23:02:23.700: E/AndroidRuntime(23092): Caused by: java.lang.ClassNotFoundException: Didn't find class "si.dvanadva.evanturist.MainActivity" on path: /data/app/si.dvanadva.evanturist-2.apk
07-16 23:02:23.700: E/AndroidRuntime(23092): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
07-16 23:02:23.700: E/AndroidRuntime(23092): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-16 23:02:23.700: E/AndroidRuntime(23092): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-16 23:02:23.700: E/AndroidRuntime(23092): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
07-16 23:02:23.700: E/AndroidRuntime(23092): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
我可以从这一行看到:
07-16 23:02:23.700: E/AndroidRuntime(23092): Caused by: java.lang.ClassNotFoundException: Didn't find class "si.dvanadva.evanturist.MainActivity" on path: /data/app/si.dvanadva.evanturist-2.apk
发现 MainActivity 类有问题。但为什么?
这就是我导入项目的方式:
导入的原始项目(没有库)
在项目的 libs 文件夹中添加了 jars
为 jar 添加了缺失的构建路径
导入三个库项目(原项目检测到)
这三个库项目都与原始项目在同一个文件夹中(以防我把它们放错了)
如果您需要任何其他信息,请告诉我,我需要解决这个问题
包及其内容:
AndroidManifest 完整代码:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="si.dvanadva.evanturist"
android:versionCode="7"
android:versionName="1.1.2"
android:installLocation="preferExternal">
<!-- ZA MAPE -->
<permission
android:name="com.dd.evanturist.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.dd.evanturist.permission.MAPS_RECEIVE"/>
<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"/>
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<!-- End of copy. -->
<!-- QR STUFF -->
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:name=".MyApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/evanturist"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDK5zGCwh3awW08BOAwupjU4hw8750WuLM"/>
<activity
android:name=".MainActivity"
android:label="@string/evanturist" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DBActivity"></activity>
<activity android:name=".DbTestActivity"></activity>
<activity android:name=".PlaceItemActivity"></activity>
<activity android:name=".CheckpointsActivity"></activity>
<activity android:name=".OptionsActivity"></activity>
<activity android:name=".MapDirectionsActivity"></activity>
<activity android:name=".VictoryActivity"></activity>
<activity android:name=".QrActivity"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
<activity android:name=".QrPortraitActivity"
android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar"></activity>
</application>
构建路径中的导出选项卡: