gpt4 book ai didi

android - 如何在android中的proguard中将公共(public)接口(interface)保留在类中

转载 作者:行者123 更新时间:2023-11-30 01:11:52 26 4
gpt4 key购买 nike

我在 android 应用程序中有一个 AB 类。此类具有一个公共(public)接口(interface) INF。当我尝试在启用 proguard 的情况下进行发布构建时,它说

错误:找不到符号类 INF

在我的 proguard.cfg 文件中,我添加了以下几行:

-keep public interface com.some.somemore.AB$INF {*;}
-keep class com.some.somemore.AB {*;}

请帮助解释为什么会出现此错误。

public class AB {

public interface INF {
public void Ready();
public void Error(int error);
public void Click();
public void Complete();
public void Dismiss();
}

这是崩溃日志

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sliq.android.sliq, PID: 14828
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sliq.android.sliq/org.nexage.sourcekit.vast.activity.VASTActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.nexage.sourcekit.vast.a.e.a()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2314)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.nexage.sourcekit.vast.a.e.a()' on a null object reference
at org.nexage.sourcekit.vast.activity.VASTActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5953)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388) 
at android.app.ActivityThread.access$800(ActivityThread.java:148) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5312) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696) 

我正在使用这个开源项目 https://github.com/nexage/sourcekit-vast-android作为我工作室项目中的一个模块。它在名为 VAST 的开源项目中崩溃。我在我的工作室项目中添加了 VAST 作为模块依赖项。我为我的工作室项目和 VAST 模块启用了混淆器。这是我用于 VAST 模块的 proguard.config 文件:

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-dontshrink
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep class org.nexage.sourcekit.vast.VASTPlayer {*;}
-keep interface org.nexage.sourcekit.vast.VASTPlayerListener {*;}
-keep class org.nexage.sourcekit.vast.model.** {*;}
-keep class org.nexage.sourcekit.vast.processor.** {*;}
-keep class org.nexage.sourcekit.vast.activity.** {*;}
-keep class org.nexage.sourcekit.util.** {*;}

最佳答案

您的实现应如下所示:

import com.my.packagename.AB;

public class MainActivity extends ActionBarActivity implements AB.TestInterface {

// other stuff

@Override
public void Ready() {

}

@Override
public void Error(int error) {

}

@Override
public void Click() {

}

@Override
public void Complete() {

}

@Override
public void Dismiss() {

}

}

需要导入父类,希望对你有帮助。

关于android - 如何在android中的proguard中将公共(public)接口(interface)保留在类中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38344211/

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