Attempt to invoke interface method 'void android.support.v7.widget.DecorContentParent.setWindowCallback(android.view.Window$Callback)'
Asked Answered
L

5

9

here is my project:

project

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>

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>

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>

LoadingActivity.java:

public class LoadingActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_loading);
    }
}

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>

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>

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'
}

why i receive the error when use 'animated-vector' at android studio 2.0 beta? 

error

the unbelievable is when i delete 'res/animator' and 'animated_path.xml',then rebuild project,it works.

it make me crazy, i don't know why,and how to solve the problem,anyone can help me ?

the terrible is,sometime it throw the error:

 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.

but i had set the style 'ActivityTheme' to the LoadingActivity.

now i post the project to the web:https://drive.google.com/open?id=0B7cSTEJuaMZBLW9VYWM5X0szVlk

Ligni answered 11/3, 2016 at 16:19 Comment(9)
What is the content of your onCreate()?Malachi
nothing,just setContentView().it throw error at setContentView()Ligni
Could you post the .zip project so We could reproduce the error?Satiable
if setContentView is causing the error, can you post your onCreate method and the layout you are loading?Auteur
ok,i post the code and the new error.Ligni
@csx Whats happens if you set buildToolsVersion "23.2.0" in your build.gradle?Satiable
the following packages are not available..Ligni
drive.google.com/open?id=0B7cSTEJuaMZBLW9VYWM5X0szVlkLigni
i ran you code in my system and its worked properly without any errorContinuative
G
7

also try "clean project"
this occurred to me even if no changes made to build version or manifest.

"Android Studio: menu> Build -> Clean Project" did it.

if this doesn't solve your problem, also try "Android Studio: menu> File -> Invalidate Caches / Restart"

Golanka answered 17/1, 2021 at 7:44 Comment(0)
S
3

Had a similar issue this morning. How I fix it:

  1. Remove application level attribute from your android manifest file android:theme="@style/AppTheme".
  2. Add activity level attribute instead like so:

    [Activity(MainLauncher = true, Theme = "@style/AppTheme")]
    
Saransk answered 16/5, 2016 at 5:42 Comment(1)
this works, however the preferred/normal android way of doing this is to add the theme in the manifest: <activity android:name=".MainActivity" android:theme="@style/AppTheme">...Tasker
R
1

'Rebuild Project' solved the problem for my project on Android Studio 2020.3.1.

Recently answered 20/12, 2021 at 13:2 Comment(0)
R
0

This issue occurs when your buildToolsVersion is not updated to match the version of playservices and other dependencies

Check here for the latest version:

https://developer.android.com/studio/releases/build-tools.html.

Retrospect answered 11/8, 2017 at 18:0 Comment(0)
M
0

In my case, I did these steps, and after them it worked:

  • Reinstall Android Studio
  • Build -> Clean Project
  • File -> Invalidate Caches
  • And Updating gradle (there was a popup bottom right)
Marciano answered 22/2, 2021 at 14:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.