gpt4 book ai didi

android - 错误在路径 : DexPathList[[zip file 上找不到类 "com.example.i.MainActivity"

转载 作者:行者123 更新时间:2023-11-29 20:22:08 25 4
gpt4 key购买 nike

如何修复以下错误。

         FATAL EXCEPTION: main
Process: com.example.i, PID: 10071
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.i/com.example.i.MainActivity}: java.lang.ClassNotFoundException: Didn't find class
"com.example.i.MainActivity" on path: DexPathList[[zip file "/data
/app/com.example.i-11.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.i-11, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2350)
at android.app.ActivityThread.access$800(ActivityThread.java:163)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1257)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
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:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.i.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.i-11.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.i-11, /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.Instrumentation.newActivity(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)

这是完整的主要 Activity

公共(public)类 MainActivity 扩展 AppCompatActivity {

        @Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);
initToolbars();
}
private void initToolbars() {

Toolbar toolbarBottom = (Toolbar) findViewById(R.id.toolbar_bottom);
toolbarBottom.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()){
case R.id.action_settings:
// TODO
break;
// TODO: Other cases
}
return true;
}
});
toolbarBottom.inflateMenu(R.menu.main);

}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();


return true;

//return super.onOptionsItemSelected(item);
}
}

这是xml

    <android.support.v7.widget.Toolbar
android:id="@+id/toolbar_bottom"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:minHeight="?attr/actionBarSize" />

</RelativeLayout>

这是风格

<resources>

<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->

<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

</resources>

libs 存在于此处 ...\workspace\i\libs 和工作场所中的 i/libs/..

最佳答案

错误:

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.i.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.i-11.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.i-11, /vendor/lib, /system/lib]]

我也遇到过这个问题。

你的 MainActivity.java 被排除在编译之外,所以这个类不包含在 .apk

.idea/compiler.xml 文件的 excludeFromCompile 部分中删除以下行

<file url="file://$PROJECT_DIR$/src/com/example/i/MainActivity.java" />

关于android - 错误在路径 : DexPathList[[zip file 上找不到类 "com.example.i.MainActivity",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33006694/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com