質問

If someone could please help point me in the right direction, I would be forever great-full! I've searched high and low, and can't seem to find a solution to this to save my life. :(

I'm having a problem compiling my application after I followed the instructions (here) to add ACRA 4.5.0 to my android project.

I ran the gradlew build and it tells me that all the org.acra imports do not exist. I added the acra-4.5.jar file to my libs folder and used android-studios 'add as library' option to add it to the project. When I write the imports android studio seems to find everything ok, and I don't have any syntax errors but it won't compile so I can test it on my device. Even though it appears the library is all in order, when I compile I receive errors.

I added the name attribute to the android manifest and everything looks fine as far as I can tell but apparently not. I'm sure I'm just missing something stupid.

I can only guess that somehow android studio didn't import the library correctly. But like I said it doesn't show any syntax errors and I'm able to Ctrl+click to the sources of each so I really don't know

Any help with this would be greatly appreciated! Thanks in advance

Edit- I also ran gradlew clean as advised in this post, but still not luck :(. After the clean was finished android studio showed syntax errors for R.* ?? I closed and reopened android studio and the syntax errors went away but the project still won't compile. It continues to say acra does not exist.

Here's my ACRA sub Application extension: /project/project/src/main/java/com/domain/project/catchEm.java

package com.domain.project;

import android.app.Application;
import org.acra.ACRA;
import org.acra.annotation.ReportsCrashes;
import org.acra.ReportingInteractionMode;


@ReportsCrashes(formKey = "", // will not be used
    mailTo = "email@email.com",
    mode = ReportingInteractionMode.DIALOG,
    resToastText = R.string.crash_toast_text,
    resDialogText = R.string.crash_dialog_text,
    resDialogIcon = android.R.drawable.ic_dialog_info,
    resDialogTitle = R.string.crash_dialog_title,
    resDialogCommentPrompt = R.string.crash_dialog_comment_prompt,
    resDialogOkToast = R.string.crash_dialog_ok_toast)

public class catchEm extends Application {
    @Override
    public void onCreate() {
        super.onCreate();

        // The following line triggers the initialization of ACRA
        ACRA.init(this);
    }
}

Here's my manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      package="com.domain.project"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_LOGS" />

<application
    android:icon="@drawable/ic_launcher"
    android:name=".catchEm"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    tools:ignore="AllowBackup">
    <activity
        android:name="com.domain.project.Main"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
            android:name=".someActivity"
            android:label="@string/label"/>

    <activity android:name="org.acra.CrashReportDialog"
              android:theme="@android:style/Theme.Dialog"
              android:launchMode="singleInstance"
              android:excludeFromRecents="true"
              android:finishOnTaskLaunch="true" />
</application>

And the Gradlew Build report

C:\Users\owner\AndroidStudioProjects\project>gradlew build
The TaskContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
:project:prepareDebugDependencies
:project:compileDebugAidl UP-TO-DATE
:project:generateDebugBuildConfig UP-TO-DATE
:project:mergeDebugAssets UP-TO-DATE
:project:compileDebugRenderscript UP-TO-DATE
:project:mergeDebugResources UP-TO-DATE
:project:processDebugManifest UP-TO-DATE
:project:processDebugResources UP-TO-DATE
:project:compileDebug

project\project\src\main\java\com\domain\project\catchEm.java:4: error: package org.acra does not exist
    import org.acra.ACRA;
                   ^

project\project\src\main\java\com\domain\project\catchEm.java:5: error: package org.acra.annotation does not exist
    import org.acra.annotation.ReportsCrashes;
                              ^

project\project\src\main\java\com\domain\project\catchEm.java:6: error: package org.acra does not exist
    import org.acra.ReportingInteractionMode;
                   ^

project\project\src\main\java\com\domain\project\catchEm.java:9: error: cannot find symbol
@ReportsCrashes(formKey = "", // will not be used
^

symbol: class ReportsCrashes

project\project\src\main\java\com\domain\project\catchEm.java:25: error: cannot find symbol
     ACRA.init(this);
     ^
symbol:   variable ACRA
location: class catchEm

5 errors
:project:compileDebug FAILED

FAILURE: Build failed with an exception.
役に立ちましたか?

解決

For some reason I checked my build.gradle file and there was no acra dependency even though android studio showed it in my dependencies list.

So I added compile files('libs/acra-4.5.0.jar') to the dependencies area in the projects build.gradle file and now everything works perfectly! Hopefully this will help someone else out also.

buildscript {

repositories {

    maven { url 'http://repo1.maven.org/maven2' }

}

dependencies {

    classpath 'com.android.tools.build:gradle:0.4'

}

}


apply plugin: 'android'



dependencies {

compile files('libs/android-support-v4.jar')

compile files('libs/acra-4.5.0.jar')
}


android {

compileSdkVersion 17

buildToolsVersion "17.0.0"


defaultConfig {

    minSdkVersion 7

    targetSdkVersion 17

}

}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top