如果有人能帮我指出正确的方向,我将永远伟大!我到处都找遍了,但似乎找不到挽救我生命的办法。(
在我按照说明(这里)将ACRA 4.5.0
添加到我的android项目后,我在编译应用程序时遇到了问题。
我运行gradlew构建,它告诉我所有的org.acra
导入不存在。我将acra-4.5.jar
文件添加到我的libs
文件夹中,并使用android-studios的"add as library"选项将其添加到项目中。当我写导入android studio似乎找到一切ok,我没有任何语法错误,但它不会编译,所以我可以在我的设备上测试它。尽管库看起来是有序的,但当我编译时,我收到错误。
我添加了名称属性到android清单,一切看起来都很好,据我所知,但显然不是。我肯定我只是错过了一些愚蠢的东西。
我只能猜测,不知何故android studio没有正确导入库。但就像我说的,它没有显示任何语法错误我可以按Ctrl+click打开每个文件的源代码所以我真的不知道
任何帮助,这将是非常感激!提前感谢
编辑- 我也按照这篇文章的建议运行了gradlew clean
,但仍然不够幸运。在清理完成后,android工作室显示R.*的语法错误??我关闭并重新打开android工作室,语法错误消失了,但该项目仍然不会编译。它继续说acra不存在。
这是我的ACRA子应用程序扩展:/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);
}
}
这是我的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>
和Gradlew Build报告
C:UsersownerAndroidStudioProjectsproject>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
projectprojectsrcmainjavacomdomainprojectcatchEm.java:4: error: package org.acra does not exist
import org.acra.ACRA;
^
projectprojectsrcmainjavacomdomainprojectcatchEm.java:5: error: package org.acra.annotation does not exist
import org.acra.annotation.ReportsCrashes;
^
projectprojectsrcmainjavacomdomainprojectcatchEm.java:6: error: package org.acra does not exist
import org.acra.ReportingInteractionMode;
^
projectprojectsrcmainjavacomdomainprojectcatchEm.java:9: error: cannot find symbol
@ReportsCrashes(formKey = "", // will not be used
^
symbol: class ReportsCrashes
projectprojectsrcmainjavacomdomainprojectcatchEm.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.
出于某种原因,我检查了我的构建。Gradle文件和没有acra依赖,即使android studio显示它在我的依赖列表。
所以我将compile files('libs/acra-4.5.0.jar')
添加到项目build.gradle
文件中的依赖项区域,现在一切都工作得很好!希望这也能帮助到其他人。
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
}
}