android - 禁用gradle中的特定 Activity 库

标签 android gradle android-gradle-plugin build.gradle

我正在开发一个具有记录音频并同时进行FFT的 Activity 的应用程序。还可以在屏幕上显示声纳等动画。为了同时进行FFT,应用程序应能快速处理。
在我的测试中,该应用在20毫秒内执行了ffts,这在android填充下一个缓冲区之前非常好。但是,在我在dependencies / build.gradle中添加了一些库之后,尽管记录 Activity 与该库无关,但它的fft持续时间急剧增加到400ms,并且无法在下一个缓冲区之前完成fft过程。它会引起问题
我的问题是;我可以禁用某些 Activity 的某些库吗?

有问题的库是“com.goseamless:seamless:2.4.0”,它是广告网络库。
为了使其运行,我需要启用multidex。
添加它并启用multidex后,会出现上述问题

android {
compileSdkVersion 21
buildToolsVersion ANDROID_BUILD_TOOLS_VERSION
//compileOptions.encoding = 'windows-1254'

defaultConfig {

    minSdkVersion ANDROID_BUILD_MIN_SDK_VERSION
    targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION
    multiDexEnabled true
}

dexOptions {
        //incremental true
        javaMaxHeapSize "2048M"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

repositories {
maven {
    url "http://maven.seamlessapi.com:8081/nexus/content/repositories/releases/"
}
}

dependencies {
compile files('libs/picasso-2.5.2.jar')
compile project(':Libraries:CropImageLib')
compile project(':Libraries:facebook-android')
compile project(':Libraries:NineOldLibs')
compile project(':Libraries:SlidingMenu')
compile files('libs/JTransforms-3.0.jar')
compile files('libs/JLargeArrays-1.2.jar')
compile files('libs/gdata-core-1.0.jar')
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.goseamless:seamless:2.4.0'
compile 'com.android.support:multidex:1.0.1'
}

任何的想法???

最佳答案

My question is; can I disable some libraries for some activities?



并非从Gradle的 Angular 来看。

eventhough that recording activity has nothing to do with that library, its fft duration increase dramatically to 400ms and it cant finish the fft process before the next buffer. and it cause problems



使用Traceview和systrace之类的工具来确定确切的时间花费在哪里。然后,找出需要做些什么来改善它。例如,也许您需要通过 Activity 的onPause()调用广告 View 上的某些方法,以使其消耗更少的CPU时间。

关于android - 禁用gradle中的特定 Activity 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31749575/

相关文章:

java - MainActivity 上的 android.view.InflateException 错误

android - 安装 Studio 2.2.1 后出现 "Gradle project refresh failed"错误(无编码!)

java - Gradle 2.0 - 加载 java 属性文件的正确方法?

maven - gradle始终使用{user.home}/repository作为Maven本地缓存

android - 如何使用 Jetpack Compose AdapterList 保留滚动位置?

android - 如何在android中显示预先选中的复选框

生成 XML 文件时出现 Android 错误

java - 如何在Android Studio上修复Gradle错误

android - 无法解析 : support-media-compat Open File

android - Gradle 构建运行无限时间