android debug

时间:2017-10-16 10:05:36

标签: android android-ndk crashlytics google-fabric crashlytics-android

我正在尝试在Android上集成Fabric(崩解与NDK支持和答案),我让它们正常工作。

然而,当我尝试调试我的应用时,结构需要很长时间(大约5分钟)来完成它的工作。

这是日志:

10-16 11:41:49.680 1534-1559/? V/WindowManager: Relayout Window{326db3dd0 u0 Starting app.company.com}: viewVisibility=0 req=2048x1536 WM.LayoutParams{(0,0)(fillxfill) sim=#20 ty=3 fl=#81830518 pfl=0x20011 wanim=0x103038a vsysui=0x600 needsMenuKey=2 naviIconColor=0}
10-16 11:41:49.701 1534-1559/? D/WindowManager: finishDrawingWindow: Window{326db3dd0 u0 Starting app.company.com} mDrawState=DRAW_PENDING
10-16 11:41:49.714 1534-1559/? I/WindowManager: Screen frozen for +113ms due to Window{326db3dd0 u0 Starting app.company.com}
10-16 11:41:49.945 21418-21684/app.company.com W/art: Verification of io.fabric.sdk.android.services.settings.Settings io.fabric.sdk.android.services.settings.Settings.initialize(io.fabric.sdk.android.Kit, io.fabric.sdk.android.services.common.IdManager, io.fabric.sdk.android.services.network.HttpRequestFactory, java.lang.String, java.lang.String, java.lang.String) took 173.644ms
10-16 11:44:51.139 21418-21684/app.company.com W/art: Verification of boolean io.fabric.sdk.android.services.settings.Settings.loadSettingsSkippingCache() took 181.194s
10-16 11:44:51.164 21418-21418/app.company.com D/libcrashlytics: Initializing libcrashlytics version 1.1.5
10-16 11:44:51.165 21418-21418/app.company.com D/libcrashlytics: Attempting to load unwinder...
10-16 11:49:24.955 21418-21684/app.company.com W/art: Verification of java.lang.String io.fabric.sdk.android.services.common.AbstractSpiCall.overrideProtocolAndHost(java.lang.String) took 303.615ms
10-16 11:49:25.366 21418-21418/app.company.com D/libcrashlytics: Done; using libunwind
10-16 11:49:25.366 21418-21418/app.company.com D/libcrashlytics: Attempting to register signal handler...
10-16 11:49:25.367 21418-21418/app.company.com D/libcrashlytics: Signal handler registered.
10-16 11:49:25.370 21418-21418/app.company.com D/libcrashlytics: Initializing native crash handling successful.

如您所见,

Verification of boolean io.fabric.sdk.android.services.settings.Settings.loadSettingsSkippingCache() took 181.194s

花了近3个月,

Attempting to load unwinder...

也取得了不错的3分钟。

当我尝试在没有调试器附件的情况下启动应用程序时(只需在android studio中运行而不是调试),该应用程序启动就可以了。

非常感谢任何寻找此问题的方向。

吉扬

编辑1:

在挖掘了一下之后,它实际上是从JniNativeApi调用

的调用
System.loadLibrary("crashlytics");

首先需要花费很多时间。不知道第二次冻结了。

这很奇怪,因为图书馆看起来很轻(libcrashlytics.so大约600ko)

编辑2:

以下是我的gradle构建的结构:

在顶层,proj.android文件夹中有一个build.gradle,它包含所有子项目共有的所有配置选项(abiFilters,minSdkVersion ......):

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

ext {
    minSdkVersion = 24
    targetSdkVersion = 26
    compileSdkVersion = 26
    buildToolsVersion = '26.0.1'
    abiFilters = [
            'XXX'
    ]
    cppDebugFlags = [
            'YYYYYY'
    ]
    cppReleaseFlags = [
            'ZZZZZ'
    ]
    arguments = [
            '-DANDROID_TOOLCHAIN=clang',
            '-DANDROID_PLATFORM=android-24',
            '-DANDROID_STL=c++_static',
            '-DANDROID_CPP_FEATURES=rtti exceptions'
    ]
}

task wrapper(type: Wrapper) {
    gradleVersion = '4.1'
}

task clean(type: Delete) {
    delete 'stuff'
}

然后我有一个build.gradle文件用于我的所有子项目(1 com.android.application和4 com.android.library)

我不认为库build.gradle文件是相关的,因为我没有在其中放置任何与结构相关的初始化,所以这是我的build.gradle主应用程序:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        // These docs use an open ended version so that our plugin
        // can be updated quickly in response to Android tooling updates

        // We recommend changing it to the latest version from our changelog:
        // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
        classpath 'io.fabric.tools:gradle:1.24.2'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    sourceSets.main {
        res.srcDir "res"
        assets.srcDirs 'sources'
        jniLibs.srcDirs "jni"
        java.srcDirs "java sources dirs"
        manifest.srcFile "AndroidManifest.xml"
    }

    defaultConfig {
        applicationId 'app.company.com'
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 2
        versionName '0.1'
        ndk {
            moduleName "moduleName"
            abiFilters rootProject.ext.abiFilters.join(",").split(",")
        }
        externalNativeBuild {
            cmake {
                cppFlags rootProject.ext.cppReleaseFlags.join(",").split(",")
                arguments rootProject.ext.arguments.join(",").split(",")
                targets "target"
            }
        }
    }

    buildTypes {
        debug {
            externalNativeBuild {
                cmake {
                    cppFlags rootProject.ext.cppDebugFlags.join(",").split(",")
                }
                // to do: swap those two lines when when debug testing will be done
                ext.alwaysUpdateBuildId = false // STACKOVERFLOW NOTE: commenting this line doesn't change anything to the problem
                //ext.enableCrashlytics = false
            }
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    externalNativeBuild {
        cmake {
            path "../../CMakeLists.txt"
        }
    }

    aaptOptions {
        cruncherEnabled = false
        noCompress 'zspine', 'zparticles', 'gz'
    }
}

crashlytics {
    enableNdk true
    manifestPath 'AndroidManifest.xml'
    // are these needed?
    // STACKOVERFLOW NOTE: I tried put the values that are given in the docs, but it doesn't seems to change anything
    //androidNdkOut 'build/intermediates/cmake/release/obj'
    //androidNdkLibsOut 'build/intermediates/bundles/default/jni'
}

// STACKOVERFLOW NOTE: here are some task definition to automatically update sources, I don't think they are relevant to the matter at hand
...

dependencies {
    compile fileTree(dir:'someJars')

    compile('com.crashlytics.sdk.android:crashlytics:2.7.0@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.6@aar') {
        transitive = true;
    }

    debugCompile project(path: ':lib1', configuration: 'debug')
    debugCompile project(path: ':lib2', configuration: 'debug')
    debugCompile project(path: ':lib3', configuration: 'debug')
    debugCompile project(path: ':lib4', configuration: 'debug')

    releaseCompile project(path: ':lib1', configuration: 'release')
    releaseCompile project(path: ':lib2', configuration: 'release')
    releaseCompile project(path: ':lib3', configuration: 'release')
    releaseCompile project(path: ':lib4', configuration: 'release')
}

我还在清单中添加了

中的api密钥
...
<application android:label="@string/app_name"
    android:icon="@drawable/icon">

    <!-- name of our .so -->
    <meta-data android:name="android.app.lib_name"
        android:value="name" />

    <meta-data android:name="io.fabric.ApiKey"
        android:value="API Key"
        />
...

最后我在我的活动的onCreate方法中设置Fabric,如下所示:

// TODO uncomment this when testing's over
//Crashlytics crashlyticsKit = new Crashlytics.Builder().core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build();
//Fabric.with(this, crashlyticsKit);

Fabric fabric = new Fabric.Builder(this).kits(new Crashlytics(), new CrashlyticsNdk())
        .debuggable(true)
        .build();
Fabric.with(fabric);

非常感谢您的快速回答,我希望其他信息能够提供帮助!

编辑3

我在几个设备上测试过(galaxy tab s3 @ 7.0&google pixel C @ 7.1.1),它没有任何区别,问题仍然存在。

1 个答案:

答案 0 :(得分:1)

我现在不完全怎么样,但是一旦我重新启动笔记本电脑,问题就消失了。我想这与adb调试器以某种方式卡住有关吗?