cs *_*s x 7 android nullpointerexception objectanimator
这是我的项目:
animated_path.xml:
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:drawable="@drawable/triangle"
tools:targetApi="21">
<target
android:name="t"
android:animation="@animator/path"/>
</animated-vector>
Run Code Online (Sandbox Code Playgroud)
path.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:duration="3000"
android:propertyName="pathData"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueFrom="M 100 100 L 300 100 L 300 300 L 100 300z"
android:valueTo="M 100 100 L 300 100 L 200 300 L 200 300z"
android:valueType="pathType"/>
</set>
Run Code Online (Sandbox Code Playgroud)
AndroidManifest.xml中:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kycq.reader">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".LoadingActivity"
android:theme="@style/ActivityTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:theme="@style/ActivityTheme">
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
LoadingActivity.java:
public class LoadingActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loading);
}
}
Run Code Online (Sandbox Code Playgroud)
activity_loading.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.kycq.reader.LoadingActivity">
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.kycq.reader"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
// enable vectorDrawable
vectorDrawables.setUseSupportLibrary(true)
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
// use 23.2.0
compile 'com.android.support:appcompat-v7:23.2.0'
}
Run Code Online (Sandbox Code Playgroud)
为什么我在android studio 2.0 beta上使用'animated-vector'时收到错误?
令人难以置信的是,当我删除'res/animator'和'animated_path.xml',然后重建项目,它的工作原理.
它让我发疯,我不知道为什么,以及如何解决问题,任何人都可以帮助我?
可怕的是,有时它会抛出错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kycq.reader/com.kycq.reader.LoadingActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
Run Code Online (Sandbox Code Playgroud)
但我已经将样式'ActivityTheme'设置为LoadingActivity.
现在我将项目发布到网上:https://drive.google.com/open? id = 0B7cSTEJuaMZBLW9VYWM5X0szVlk
也尝试“干净的项目”,
即使没有对构建版本或清单进行任何更改,这也发生在我身上。
"Android Studio: menu> Build -> Clean Project"
做到了。
如果这不能解决您的问题,也请尝试
"Android Studio: menu> File -> Invalidate Caches / Restart"
今天早上也有类似的问题。我如何修复它:
android:theme="@style/AppTheme"。添加活动级别属性,如下所示:
[Activity(MainLauncher = true, Theme = "@style/AppTheme")]
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
3531 次 |
| 最近记录: |