[英]Upgraded Android Studio… now when I try to run my apps, I get “No implementation found” for my main activity
Upgraded Android studio (stupid, right?).升级了 Android 工作室(愚蠢,对吧?)。 Now not only can I not hit alt-E, C to do a copy, but some older apps of mine, that I need to support, no longer run.现在我不仅不能按 alt-E、C 进行复制,而且我需要支持的一些较旧的应用程序不再运行。 These are apps that were put together with Android Studio 1.x.这些是与 Android Studio 1.x 放在一起的应用程序。
First off, when I tried to compile, it demanded that I put "-keepattributes InnerClasses" in my proguard rules.首先,当我尝试编译时,它要求我将“-keepattributes InnerClasses”放入我的 proguard 规则中。 Just including that in case it's some kind of hint.只是包括它,以防万一它是某种暗示。
The program compiles fine, but then it runs and quits instantly.该程序编译得很好,但它会立即运行并退出。 Looking at Logcat, I see this:看着 Logcat,我看到了这个:
2021-03-18 22:02:34.960 6147-6147/com.mycompany.myapp E/ycompany.myapp: No implementation found for java.lang.String com.mycompany.myapp.myappActivity.d() (tried Java_com_mycompany_myapp_myappActivity_d and Java_com_mycompany_myapp_myappActivity_d__)
Here's the weird part, though... in myactivity onCreate, I output a line of text.不过,这是奇怪的部分……在 myactivity onCreate 中,我 output 一行文本。 It gets there.它到达那里。 That happens.那个会发生。 It prints out ">>>>>CREATED APP<<<<<"它打印出 >>>>>>创建的应用程序<<<<<"
Can anyone explain what's happening?谁能解释发生了什么? What do I need to do to fix this???我需要做什么来解决这个问题???
A lot has changed since ASs 1.x especially with the gradle / android gradle plugin.自 ASs 1.x 以来发生了很多变化,尤其是使用 gradle / android gradle 插件。 These are very finicky even after minor updates.即使在小更新之后,这些也非常挑剔。 Nevertheless you're more or less forced to update to a newer (not necessarily the newest) IDE version.尽管如此,您或多或少还是被迫更新到更新的(不一定是最新的)IDE 版本。 Not finding java.lang.String suggests some major incompatibility issue.未找到 java.lang.String 表明存在一些重大的不兼容问题。
First you should check your JDK version (and ensure you have the full kit not just a JRE).首先,您应该检查您的 JDK 版本(并确保您拥有完整的工具包,而不仅仅是 JRE)。 Not all IDE versions work with all JDKs and again use an older one (10, 12), not the absolute bleeding edge as the newest might not be supported (and android does not support newer java features anyway).并非所有 IDE 版本都适用于所有 JDK,并再次使用较旧的版本(10、12),而不是绝对前沿,因为可能不支持最新版本(并且 android 无论如何都不支持较新的 Z93F725A07423FE1C886ZD4 功能)。 I use JDK 12 and Ass 3.6.1.我使用 JDK 12 和 Ass 3.6.1。 Also check the gradle version you're using since gradle also has its incompatibilities.还要检查您使用的 gradle 版本,因为 gradle 也有其不兼容性。 Remember to also inspect the contents of JAVA_HOME and GRADLE_HOME environment variables (if they exist and are used by your project) since they may override the build tool versions that are used.请记住还要检查 JAVA_HOME 和 GRADLE_HOME 环境变量的内容(如果它们存在并且被您的项目使用),因为它们可能会覆盖所使用的构建工具版本。
Your safest bet would be to create a new empty project and copy all your sources in it.您最安全的选择是创建一个新的空项目并将所有源代码复制到其中。 That might take less time then trying to clean the existing project, migrate the plugins, gradle and so on.这可能比尝试清理现有项目、迁移插件、gradle 等花费更少的时间。
Until you fix the project setup you can disable proguard to get rid of one more hassle by setting minifyEnabled false
in your app/ build.gradle # buildTypes # release.在您修复项目设置之前,您可以通过在您的应用程序/ build.gradle # buildTypes # release 中设置minifyEnabled false
来禁用 proguard 以摆脱更多麻烦。 Note that proguard is usually disabled for debug builds.请注意,对于调试版本,通常禁用 proguard。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.