【问题标题】:AndroidRuntime: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{.../....MainActivity}: java.lang.ClassNotFoundException:AndroidRuntime: java.lang.RuntimeException: 无法实例化活动 ComponentInfo{.../....MainActivity}: java.lang.ClassNotFoundException:
【发布时间】:2018-07-12 13:19:03
【问题描述】:

多年来,我一直通过 Windows CLI 使用 cordova,没有遇到任何问题。自从更新到 cordova 8.0.0 后,Android 版本将不会在设备或模拟器上运行。

据我所知,我现在已经卸载并重新安装了所有内容。现在只使用 helloworld 默认项目进行测试,仍然遇到同样的问题。启动时它只显示 HelloWorld 已停止。

每个 apk 结果:

AndroidRuntime: java.lang.RuntimeException: 无法实例化 活动 组件信息{com.example.hello/com.example.hello.MainActivity}: java.lang.ClassNotFoundException:找不到类 路径上的“com.example.hello.MainActivity”:DexPathList [[zip 文件 "/data/app/com.example.hello-ZStkpWQT_YEARbjw--2a6Q==/base.apk"]

在这里尝试了所有相关的建议,但仍然没有任何乐趣。

目前: 科尔多瓦 8.0.0 Java JDK:1.8.0.91 分级:4.4 npm:6.1.0 安卓:7.0.0 安卓目标:26

hello\platforms\android\app\src\main\AndroidManifest.xml 由科尔多瓦创建

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="com.example.hello" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
</manifest>

任何建议将不胜感激。

提前致谢。

【问题讨论】:

  • 您应该检查清单中的 $ 使用情况,它会破坏代码并产生类似的崩溃错误。

标签: android cordova cordova-android cordova-8.0.0


【解决方案1】:

只需点击文件按钮 Invalidate Cashe 并重新启动,大多数情况下都可以正常工作

【讨论】:

    【解决方案2】:

    [已解决] 随着所有更新,环境变量似乎已经不同步,并且一定有一些卸载遗留下来的东西,这意味着它看起来正在正确构建。更新了这些,现在一切正常。

    路径:

    C:\...\Android\Sdk
    C:\...\Android\Sdk\emulator
    C:\...\Android\Sdk\gradle\bin
    C:\...\Android\Sdk\platform-tools
    C:\...\Android\Sdk\tools\bin
    C:\...\Android\Sdk\build-tools

    另请参阅 https://www.fiznool.com/blog/2017/05/30/a-guide-to-installing-cordova-on-windows-10/,它促使我调查安装的每个元素。

    【讨论】:

      猜你喜欢
      • 2016-11-17
      • 2015-03-04
      • 2013-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-08
      • 1970-01-01
      相关资源
      最近更新 更多