我在向我的应用添加自定义图片时遇到问题。当我这样做时,我得到了gradle错误。我在这里搜索并看到了要添加的解决方案:
android: {
useNewCruncher false
}
但这没有帮助。我仍然得到“非零退出值42错误”。这是我的gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
aaptOptions {
useNewCruncher false
}
defaultConfig {
applicationId "net.androidbootcamp.techgadgets"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
}
以下是大多数的gradle错误
错误:错误:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:处理'命令'/Users/SlyInstinct/Library/Android/sdk/build-tools/23.0。 2 / aapt''以非零退出值42完成
:app:mergeDebugResources FAILED
错误:任务':app:mergeDebugResources'的执行失败。 /Users/SlyInstinct/Documents/AppProjects/AndroidStudioProjects/TechGadgets/app/src/main/res/drawable/butler.png:错误:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException :进程'命令'/Users/SlyInstinct/Library/Android/sdk/build-tools/23.0.2/aapt''以非零退出值结束42 这是Java的主要活动
package net.androidbootcamp.techgadgets;
import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends ListActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String [] tech ={"Self Driving Car", "Bionic Butler", "Jetpack", "Robot Dogs", "Virtual Reality"};
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, tech));
}
protected void onListItemClick(ListView l, View v, int position, long id) {
switch(position){
case 0:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com/selfdrivingcar/")));
break;
case 1:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://en.wikipedia.org/wiki/Artificial_intelligence")));
break;
case 2:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.martinjetpack.com/")));
break;
case 3:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.bostondynamics.com/robot_bigdog.html")));
break;
case 4:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.oculus.com/en-us/")));
break;
}
}
}
这是logcat
03-06 19:59:16.970 1296-1296/? E/LocationManagerService: no geocoder provider found
03-06 19:59:16.970 1296-1296/? E/FlpHardwareProvider: Error hw_get_module 'flp': -2
03-06 19:59:16.970 1296-1296/? E/LocationManagerService: FLP HAL not supported
03-06 19:59:16.970 1296-1296/? W/ServiceWatcher: com.google.android.location not found
03-06 19:59:16.970 1296-1296/? E/LocationManagerService: Unable to bind FLP Geofence proxy.
03-06 19:59:16.970 1296-1296/? E/ActivityRecognitionHardware: Error hw_get_module: -2
03-06 19:59:16.970 1296-1296/? E/LocationManagerService: Hardware Activity-Recognition not supported.
03-06 19:59:16.970 1296-1313/? E/GpsLocationProvider: no AGPS interface in set_agps_server
03-06 19:59:16.990 1296-1296/? I/CommonTimeManagementService: No common time service detected on this platform. Common time services will be unavailable.
03-06 19:59:16.990 1296-1296/? I/MmsServiceBroker: Connecting to MmsService
03-06 19:59:16.990 1296-1296/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1750 com.android.server.MmsServiceBroker.tryConnecting:134 com.android.server.MmsServiceBroker.systemRunning:121 com.android.server.SystemServer$2.run:1182 com.android.server.am.ActivityManagerService.systemReady:11326
03-06 19:59:16.990 1296-1331/? I/InputReader: Reconfiguring input devices. changes=0x00000030
03-06 19:59:17.000 1419-1419/? E/SQLiteLog: (283) recovered 30 frames from WAL file /data/data/com.android.providers.media/databases/external.db-wal