我是android的新手,所以可能会遗漏一些明显的东西。
我正在运行小型服务来模拟一些呼叫,但是服务有时会重新启动中间任务。它并不总是相同的任务,有时它根本不会发生。
服务重启时产生的错误:
10-13 13:49:14.469 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Lcom/android/tools/fd/runtime/Server$SocketServerThread;
10-13 13:49:14.481 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Ltest/callsimulator/SimulatorService;
10-13 13:49:14.483 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Ltest/callsimulator/TestCase;
10-13 13:49:14.484 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Lcom/android/tools/fd/runtime/IncrementalChange;
10-13 13:49:14.486 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Lcom/android/tools/fd/runtime/InstantReloadException;
10-13 13:49:14.488 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Ltest/callsimulator/CaseInfo;
10-13 13:49:14.489 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Ltest/callsimulator/SimulatorService$1;
10-13 13:49:14.489 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Ltest/callsimulator/SimulatorService$2;
10-13 13:49:14.491 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Ltest/callsimulator/TransferHelper;
10-13 13:49:14.498 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Lorg/apache/commons/io/IOUtils;
10-13 13:49:14.503 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Ltest/callsimulator/SimulatorService$5;
10-13 13:49:14.504 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Ltest/callsimulator/SimulatorService$6;
10-13 13:49:14.505 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Ltest/callsimulator/SimulatorService$4;
10-13 13:49:14.507 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Ltest/callsimulator/SimulatorService$3;
10-13 13:49:14.510 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Landroid/support/v4/app/ActivityCompat;
10-13 13:49:14.513 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Landroid/support/v4/content/ContextCompat;
10-13 13:49:14.533 20691-20691/test.callsimulator D/CallSimulator: Sim number; 89450100140117176259
10-13 13:49:14.542 20691-20691/test.callsimulator V/HwPolicyFactory: : success to get AllImpl object and return....
10-13 13:49:14.544 20691-20691/test.callsimulator V/HwWidgetFactory: : successes to get AllImpl object and return....
10-13 13:49:14.627 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Lorg/apache/commons/io/output/StringBuilderWriter;
10-13 13:49:14.632 20691-20691/test.callsimulator E/art: ClassLinker::FindClass not found:Lorg/apache/commons/io/Charsets;
如果我打开应用程序,我会收到更多上述类型的错误,但它们对应用程序没有任何直接影响。应用程序中的活动只会启动服务(如果尚未启动)。
我发现类似的问题,答案似乎都指向gradle属性文件,添加支持库下载丢失的软件包,但他们的解决方案对我没有用。
在应用程序文件夹中build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "test.callsimulator"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:support-v13:24.2.1'
}
项目文件夹中的build.gradle:
// 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.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我缺少什么?
答案 0 :(得分:2)
很难说,但这似乎是与您正在使用的gradle版本或Instant Run相关的问题。 我的建议是:
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.2.2'
的Android gradle插件
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip)
更新后,Android Studio应立即执行第2步和第3步。
清理并重建您的项目。
如果这不能解决您的问题,请尝试禁用即时运行(AndroidStudio - >偏好设置 - >构建,执行,部署 - >即时运行 - >取消选中'启用即时运行热插拔代码/资源部署')的变化。
再次清理并重建您的项目。
最后,它可能是一个与您正在使用的库/方法数量相关的问题(您在libs文件夹中使用了一些jars文件吗?)。按照此guide启用multidex。
当然:清洁和重建:)
答案 1 :(得分:1)
1.转到项目结构 - >依赖
2.点击' +'在右上角选择"图书馆 依赖"
3.在搜索字段中键入要添加的库.ex您要添加" org.apache.directory.studio:org.apache.commons.io"。
4.选择并添加此库。
OR
5.清除应用缓存。
6.无效缓存/重启Android工作室。
(快乐编码:))
答案 2 :(得分:1)
您正在 ClassNotFoundException 。
ClassNotFoundException当Java虚拟机尝试加载时出现 特定的类,并没有在类路径中找到所请求的类。
检查您的类路径是否包含 jar或编译库,如果 您的 classpath不包含 jar或编译库然后只需添加 你的类路径中的那个类。
对于新来者来说,这是最常见的问题。你可以查看这个答案。
然后清洁 - 重建&运行你的项目。
<强> FYI 强>
请勿从Gradle部分调用相同的库 。如果在gradle部分中添加相同的jar,则会出现Duplicate zip entry
编译时错误。
答案 3 :(得分:0)
我认为问题在于行的gradle配置
compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
问题可能是您尝试编译的jar文件可能不会出现在您的sdk库中。
我可以说解决方案是从Maven存储库下载所需的Apache jar并将其作为库添加到您的项目中(给定的Url也有该部分)。
以下链接对您解决问题非常有帮助
答案 4 :(得分:0)
此处出现问题compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
您需要下载jar文件并将其放在lib文件夹中。然后将其包含在您的gradle依赖项中
答案 5 :(得分:0)
尝试删除proguard配置
Verift the Actiivty&amp;服务文件被忽略。
或保持Activty&amp;要求的课程加上
-keep class。**
答案 6 :(得分:0)
只是一个想法,但你有所有必要的进口吗?所有的支持库?