Tag: dex

Kotlin内联函数和Android方法计数

我想了解内联函数如何影响classes.dex和方法的数量。 从我的理解来看,内联函数应该有比方法计数少的开销。 然而,APK分析器给了我相反的结果。 我写了一个小测试来检查这个。 InlineFunction.kt文件: inline fun inlined(block: () -> Unit) { block() } 和MainActivity.kt文件: class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) inlined { println(“Inlined”) } } } 从生成的代码的角度来看,它看起来很清楚: public final class MainActivity extends AppCompatActivity { private HashMap _$_findViewCache; protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); String var2 = “Inlined”; System.out.println(var2); […]

在Android库中显示类选择器

我正在创建一个库,我想创建一个类选择器。 当一个编辑文本被点击时,它会显示一个对话框,其中我将显示当前应用程序中的所有包和类。 用户可以从中选择一个班级。 我尝试了一些挣扎了2个小时。 但无法弄清楚如何做到这一点。 我看到这个答案使用DexFile 。 不过,从API 26开始已经被弃用了。

重复的zip文件))

这个问题与我在这里开始的其他人有很大关系: 将multidex添加到我的应用程序后,由于“java.lang.NoClassDefFoundError”,检测仪运行失败 无法合并dex – 如何排除适当的jar? 我添加了multidex支持,然后还添加了测试的支持。 我还添加了我的包装选项的例外,但它不工作,因为我认为。 这是我的build.gradle现在: apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' android { compileSdkVersion 26 buildToolsVersion "26.0.2" packagingOptions { exclude 'protobuf.meta' exclude 'android/support/test/filters/RequiresDevice.class' } testOptions { unitTests { includeAndroidResources = true } } sourceSets { test.java.srcDirs += ['build/generated/source/apt/test/debug'] } defaultConfig { multiDexEnabled true minSdkVersion 15 targetSdkVersion 26 versionCode 1 […]

无法合并dex

你好我有Android Studio Beta。 我创建新的项目与编译我的旧模块,但是当我尝试启动应用程序。 应用程序没有启动消息。 Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. com.android.builder.dexing.DexArchiveMergerException:无法合并dex 但我不知道如何解决这个错误我GOOGLE了几个小时,但不成功。 我的项目gradle: // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0-beta6' classpath "io.realm:realm-gradle-plugin:3.7.1" classpath 'com.google.gms:google-services:3.1.0' // NOTE: Do not place your application dependencies here; they belong // in […]

在Android 4.4上添加Kotlin配置后,DexFile不包含生成的类

我有一些自定义注释与注释处理在我的应用程序中生成一些新的类。 然后我使用DexFile找到所有这些文件。 final String apkName = context.getPackageManager() .getApplicationInfo(context.getPackageName(), 0).sourceDir; final DexFile dexFile = new DexFile(apkName); final PathClassLoader classLoader = new PathClassLoader( apkName, Thread.currentThread().getContextClassLoader()); final Enumeration<String> entries = dexFile.entries(); VelocityEngine从模板和注释类中生成类。 问题是当我在我的项目中配置Kotlin我生成的类不在DexFile了,如果我的应用程序运行在Android 4.4。 在Android 6.0上一切正常。 当我试图给项目添加一些额外的依赖时,同样的情况发生在我身上。 我使用Android Studio 2.1.2和摇篮插件2.1.2。