Java 问题多次出现,通过禁用Instant Run

Java 问题多次出现,通过禁用Instant Run,java,android,c++,android-ndk,Java,Android,C++,Android Ndk,解决了所有问题。在我的案例中,这个问题是因为Kotlin而出现的。在我现有的代码中,有一个类是用Kotlin编写的。我创建了这个应用程序,并安装了它。当第一个活动打开时,这个应用程序就崩溃了。在logcat中显示此错误。然后,我在应用程序gradle文件中从Kotlin网站更新了我的Kotlin版本。再次构建应用程序,然后运行正常。如果在应用程序升级文件中启用了minifyEnabled和将资源压缩为true。您需要在proguard rules.pro文件中添加以下行 -保持类com.your

解决了所有问题。在我的案例中,这个问题是因为Kotlin而出现的。在我现有的代码中,有一个类是用Kotlin编写的。我创建了这个应用程序,并安装了它。当第一个活动打开时,这个应用程序就崩溃了。在logcat中显示此错误。然后,我在应用程序gradle文件中从Kotlin网站更新了我的Kotlin版本。再次构建应用程序,然后运行正常。

如果在应用程序升级文件中启用了
minifyEnabled
将资源压缩为true。您需要在
proguard rules.pro
文件中添加以下行

-保持类com.yourpackage_name.*{*}


因为缩小被删除了apk文件中的一些重要类

我以前也有过这个问题,这里的评论在过去很有帮助,但这次没有。我检查了我的proguard配置,并删除了以下行,然后它工作了,因此proguard可能与此错误有关:

 -optimizationpasses 5
        -overloadaggressively
        -repackageclasses ''
        -allowaccessmodification
        -dontskipnonpubliclibraryclassmembers
Ashik abbas(禁用即时跑步)适合我,但我需要即时跑步,最后我找到了对我有用的解决方案。 只需禁用minifyEnabled。 转到调试中的build.gradle(模块:app)阻止并禁用minifyEnabled

debug {
            minifyEnabled false

        }

在我的例子中,我使用旧的名称空间库,而我的项目是使用androidx one建立的


解决方案是将
android.support.design.widget.BottomNavigationView
组件替换为从支持库中退出的正确组件:
com.google.android.material.bottomnavigation.BottomNavigationView

一个可能的原因是Apps AndroidManifest.xml文件中的活动路径不正确。 在您的AndroidManifest.xml中使用完整的相对路径注册活动,如下所示

<activity android:name="<full_path>.ActivityName" />

在我的例子中,我在
Manifest.xml
中定义了活动,但忘记创建任何
活动。

因此,我创建了活动,并在
清单
中定义它,我的错误得到了解决

对于现在遇到这个问题的任何人,使用android studio 4.0+只需启用java 8即可


我将使用@hofs,但显示应该在哪里启用minify

在模块Gradle中,在调试块中添加minifyEnabled false将对我有效

 android {
    compileSdkVersion 28
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.korechi.roamioapp"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
          minifyEnabled false
        }
    }

}



你在使用外部jar文件吗?@SiddharthVyas不,我在这里没有使用外部jar文件。你的应用程序是多索引的吗?如果是这样的话,那么这就解释了问题所在。当我执行签名apk时,这个错误没有发生。刚刚调试您找到了一个有效的解决方案吗?文件夹名为libs only添加多个索引仅在您超过引用计数限制(56k)时才有用,而且在使用棒棒糖之前非常不稳定和不可靠。这应该是用来解决问题的最后手段。那么根据您的意见应该是什么解决方案好的谢谢您提供的信息,如果您找到了一个好的解决方案,请在这里更新,这将是一个很大的帮助。添加上面的依赖项行为我做到了这一点。完成后,我需要清理和重建这个项目。这是解决这个问题的正确方法。我已经用我的libgdx游戏测试了这一点,发现了与上面相同的错误。我使用手机(三星galaxy S6)生成的日志发现了这些错误。一旦我应用了这个解决方案,我所有的问题都解决了。我无法从项目的右键单击中找到属性。也许我很愚蠢(我也找不到属性,有人知道如何导航到列出的页面吗?这是一个Eclipse IDE解决方案。Android Studio中没有默认的“project.properties”文件。它可以创建。提供的解决方案仅适用于Eclipse IDE。请不要将添加到多个问题。回答最好的问题,并标记为。)e rest是重复的。这是Android Studio的正确答案。我不敢相信Instant Run仍然存在如此多的问题,以至于为了避免令人不快的意外,你必须关闭它……我已经寻找这个答案好几天了,甚至好几周了!虽然不是很关键,但这个问题一直在我脑海中,没有给我安宁。从未想过instant run是触发此问题的原因。我的应用程序在通过adb启动时运行良好,但在通过apk手动安装时总是因ClassNotFound runtime expection而崩溃。这不是我的解决方案。我在禁用选项后禁用了instant run。请重新启动你的android studioomg我不知道为什么会使用instant run罪魁祸首,但确实是,谢谢伙计,在“建造”下菜单。选择Build->Clean Project,然后选择Build->Rebuild Project这意味着应用程序只在本地崩溃,但崩溃也发生在发布版本中,因此这不是一个真正的解决方案。尝试了多种解决方案,这个小东西解决了问题,难以置信!@FraK,评级最高的解决方案包含此建议。尽管我已经dy unchecked Instant Run(几年来它带来了很多bug)。Android Studio 3.1+默认使用这个dex编译器,但它没有帮助我(三星Galaxy S4,Android 5.0.1)。如果从
应用程序
扩展,我们应该重写此方法。在
多索引应用程序
的情况下,为什么要重写?启用多索引
如何影响?在我的情况下
javaMaxHeapSize“4g”
没有帮助。@CoolMind它只是一个扩展了
MultiDexApplication
的应用程序类。如果你想使用multidexage,它是必需的。我使用
MultiDexApplication
attachBaseContext
(请参见)。哇,我有一个99%的Kotlin项目要做什么?:)你能检查一下吗,with Kotlin版本与底层Android Studio兼容。这只是猜测。看看我的AS 3.3.1和Kotlin 1.3.21。他们是最新的马厩。对不起,我想,上面和下面描述的所有解决方案都不适合我的情况。这是因为另一个原因。检查你的拼写
<activity android:name="android.app.POMActivity"
<activity android:name=".POMActivity"
<activity android:name="com.irrlicht.example1.POMActivity"
Right click on my main library > 
Properties > 
Android > 
Go to the very bottom of the screen and click (Add) > 
Select my other library that caused the crash >
Apply
defaultConfig {
    ...
    minSdkVersion 14
    targetSdkVersion 21
    ...

    // Enabling multidex support.
    multiDexEnabled true
}

 dependencies {
     compile 'com.android.support:multidex:1.0.0'
 }
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'
}
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();

    }
}
 <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">
@Override
protected void attachBaseContext(Context base)
{
    super.attachBaseContext(base);
    MultiDex.install(BaseApplication.this);
}
compile 'com.android.support:multidex:1.0.1'
<com.example.MyView
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
defaultConfig {
      ...

      // Enabling multidex support.
      multiDexEnabled true
}

dependencies {
     ... 
     compile 'com.android.support:multidex:1.0.2'
}
dexOptions {
     preDexLibraries false
}
 -optimizationpasses 5
        -overloadaggressively
        -repackageclasses ''
        -allowaccessmodification
        -dontskipnonpubliclibraryclassmembers
debug {
            minifyEnabled false

        }
<activity android:name="<full_path>.ActivityName" />
android {
    defaultConfig {
            ...
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
 android {
    compileSdkVersion 28
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.korechi.roamioapp"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
          minifyEnabled false
        }
    }

}