简体   繁体   English

Android应用无法安装

[英]Android app cannot install

While developing an app in AIDE for Android I have come across this error. 在AIDE中为Android开发应用程序时,遇到了此错误。 The app would compile successfully but wouldn't install, reporting this error: 该应用程序将成功编译但无法安装,并报告以下错误:

Could not run the App directly as root. 无法直接以root用户身份运行该应用程序。 Consider disabling direct running in the settings. 考虑在设置中禁用直接运行。

WARNING: linker: app_process has text relocations. 警告:链接器:app_process具有文本重定位。 This is wasting memory and is a security risk. 这浪费了内存,并且存在安全风险。 Please fix. 请解决。
pkg: /storage/sdcard/AppProjects/MyProgram/bin/MyProgram.apk pkg:/storage/sdcard/AppProjects/MyProgram/bin/MyProgram.apk
Failure [INSTALL_FAILED_DEXOPT] 失败[INSTALL_FAILED_DEXOPT]
exit with 0 以0退出

I researched what could cause this and mainly came across reasons like "certificate error, try resigning the package" and "setting a permission twice in the manifest" and other stuff, none of which have worked. 我研究了可能导致这种情况的原因,并且主要遇到了诸如“证书错误,尝试重新签发程序包”和“在清单中两次设置权限”之类的原因,但没有任何一个起作用。

Your problem: Java thinks you define two methods with the same signature. 您的问题:Java认为您定义了两个具有相同签名的方法。

Java method signature definition: https://docs.oracle.com/javase/tutorial/java/javaOO/methods.html Java方法签名定义: https : //docs.oracle.com/javase/tutorial/java/javaOO/methods.html

method declarations have six components, in order: 方法声明按顺序包含六个部分:

1.Modifiers—such as public, private, and others you will learn about later. 1.修饰符-诸如公共,私有和其他您将在以后学习的修饰符。

2.The return type—the data type of the value returned by the method, or void if the method does not return a value. 2.返回类型-方法返回的值的数据类型;如果该方法未返回值,则返回void。

3.The method name—the rules for field names apply to method names as well, but the convention is a little different. 3.方法名称-字段名称的规则也适用于方法名称,但是约定有所不同。

4.The parameter list in parenthesis—a comma-delimited list of input parameters, preceded by their data types, enclosed by parentheses, (). 4.括号中的参数列表-输入参数的逗号分隔列表,其输入的数据类型前面带有括号()。 If there are no parameters, you must use empty parentheses. 如果没有参数,则必须使用空括号。

  1. An exception list—to be discussed later. 例外列表-稍后再讨论。
  2. The method body, enclosed between braces—the method's code, including the declaration of local variables, goes here. 括号之间的方法主体(此处是方法的代码,包括局部变量的声明)在此处。

As you can see above, the specification of generic classes is NOT part of the java method signature. 从上面可以看到,泛型类的规范不是java方法签名的一部分。 Therefore java detects two add-methods with the same signature. 因此,java检测到两个具有相同签名的添加方法。

I found where the problem resides. 我找到了问题所在。 It was in some code which looked very much like this: 它在某些代码中看起来非常像这样:

public class Builder<T extends Base> {
    private final List<Def1> subDefs1 = new ArrayList<>();
    private final List<Def2> subDefs2 = new ArrayList<>();

    public Builder<T> add(final Collection<Def1> ds) {
        subDefs1.addAll(ds);
        return this;
    }

    public Builder<T> add(final Collection<Def2> ds) {
        subDefs2.addAll(ds);
        return this;
    }
}

interface Base {}

final class Def1 implements Base {}

final class Def2 implements Base {}

I had these add methods, which both take a Collection of some kind. 我有这些add方法,它们都采用某种Collection The problem must be something to do with Java's lacklustre generics and the dexing process, I guess... 我想这个问题一定与Java乏善可陈的泛型和dexing过程有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM