我没有在我的代码中直接使用任何RippleDrawable实例或库,每当我编译我的应用程序时崩溃和android监视控制台状态无法找到类'android.graphics.drawable.RippleDrawable',从方法android引用。 support.v7.widget.AppCompatImageHelper.hasOverlappingRendering。
以下是主要活动的代码。
package com.example.weatherapp;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import org.w3c.dom.Text;
public class MainActivity extends AppCompatActivity {
static TextView placeTextView;
static TextView tempTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
placeTextView = (TextView) findViewById(R.id.nametextview);
tempTextView = (TextView) findViewById(R.id.temptextview);
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
String provider = locationManager.getBestProvider(new Criteria(), false);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
Location location = locationManager.getLastKnownLocation(provider);
Double lng = location.getLongitude();
Double lat = location.getLatitude();
DownloadTask task = new DownloadTask();
task.execute("http://api.openweathermap.org/data/2.5/weather?lat=" + String.valueOf(lat) + "&lon=" + String.valueOf(lng) + "&appid=6cf59e488bc16d70d20fa680e619b60e");
}
} 我认为错误是在权限检查中。但不知道该怎么做。 这是我的应用程序的默认配置。
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.weatherapp"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
依赖{ 编译fileTree(dir:'libs',包括:['* .jar']) testCompile'junit:junit:4.12' 编译'com.android.support:appcompat-v7:25.3.0' }
这是activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.weatherapp.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/nametextview"
android:textColor="#000000"
android:textSize="25sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/temptextview"
android:textColor="#000000"
android:textSize="25sp"/>
</LinearLayout>
和堆栈跟踪
05-17 13:53:47.190 17235-17235/com.example.weatherapp I/dalvikvm: Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts
05-17 13:53:47.190 17235-17235/com.example.weatherapp W/dalvikvm: VFY: unable to resolve interface method 16343: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V
05-17 13:53:47.190 17235-17235/com.example.weatherapp W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
05-17 13:53:47.190 17235-17235/com.example.weatherapp I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
05-17 13:53:47.190 17235-17235/com.example.weatherapp W/dalvikvm: VFY: unable to resolve interface method 16345: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
05-17 13:53:47.190 17235-17235/com.example.weatherapp I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
05-17 13:53:47.190 17235-17235/com.example.weatherapp W/dalvikvm: VFY: unable to resolve interface method 16349: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
05-17 13:53:47.190 17235-17235/com.example.weatherapp I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
05-17 13:53:47.190 17235-17235/com.example.weatherapp W/dalvikvm: VFY: unable to resolve virtual method 468: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
05-17 13:53:47.200 17235-17235/com.example.weatherapp I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
05-17 13:53:47.200 17235-17235/com.example.weatherapp W/dalvikvm: VFY: unable to resolve virtual method 490: Landroid/content/res/TypedArray;.getType (I)I
05-17 13:53:47.230 17235-17235/com.example.weatherapp I/dalvikvm: Could not find method android.widget.FrameLayout.startActionModeForChild, referenced from method android.support.v7.widget.ActionBarContainer.startActionModeForChild
05-17 13:53:47.230 17235-17235/com.example.weatherapp W/dalvikvm: VFY: unable to resolve virtual method 16780: Landroid/widget/FrameLayout;.startActionModeForChild (Landroid/view/View;Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
05-17 13:53:47.240 17235-17235/com.example.weatherapp I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v7.content.res.AppCompatResources.getColorStateList
05-17 13:53:47.240 17235-17235/com.example.weatherapp W/dalvikvm: VFY: unable to resolve virtual method 282: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
05-17 13:53:47.250 17235-17235/com.example.weatherapp I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
05-17 13:53:47.250 17235-17235/com.example.weatherapp W/dalvikvm: VFY: unable to resolve virtual method 431: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
05-17 13:53:47.250 17235-17235/com.example.weatherapp I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
05-17 13:53:47.250 17235-17235/com.example.weatherapp W/dalvikvm: VFY: unable to resolve virtual method 433: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
05-17 13:53:47.260 17235-17235/com.example.weatherapp E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
05-17 13:53:47.260 17235-17235/com.example.weatherapp W/dalvikvm: VFY: unable to resolve instanceof 141 (Landroid/graphics/drawable/RippleDrawable;) in Landroid/support/v7/widget/AppCompatImageHelper;
05-17 13:53:47.300 17235-17235/com.example.weatherapp W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x418edc80)
05-17 13:53:49.770 17235-17235/com.example.weatherapp I/Process: Sending signal. PID: 17235 SIG: 9