maxmpz / powerampapi

Poweramp APIs
Other
236 stars 95 forks source link

Sample Skins always crashes #13

Closed ghost closed 6 years ago

ghost commented 6 years ago

I'm trying to run the sample skin as is to see it running before I start changing styles, but even if it builds correctly it crashes at runtime.

The only thing I changed initially was the path for additionalParameters in build.gradle. It built successfully. Later I tried to change the app package and some values in skins.xml and in the styles but the errors persisted. Note that this happens with both the normal and the alternative sample skin.

  1. If I try to open it with the "Start Poweramp With * Skin" button, I get this error:

    E/BaseActivity: android.view.InflateException: File: com.maxmpz.audioplayer:layout/activity_list_fast -> Binary XML file line #53: Binary XML file line #53: You must supply a layout_width attribute.
    Caused by: java.lang.UnsupportedOperationException: Binary XML file line #53: You must supply a layout_width attribute.
        at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:775)
        at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:7554)
        at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:7746)
        at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:439)
        at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:370)
        at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:368)
        at qa.l1l1(":1013)
        at qa.l1l1(":846)
        at sm.l1l1(":278)
        at qa.inflate(":403)
        at qa.inflate(":352)
        at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:419)
        at android.app.Activity.setContentView(Activity.java:2674)
        at com.maxmpz.audioplayer.BaseActivity.l1l1(":551)
        at com.maxmpz.audioplayer.BaseActivity.setContentView(":546)
        at com.maxmpz.audioplayer.ListActivity.onCreate(":105)
        at android.app.Activity.performCreate(Activity.java:7054)
        at android.app.Activity.performCreate(Activity.java:7045)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2732)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2857)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1590)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6499)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
    E/BaseActivity: handleLayoutFailure=>resetSkinOnFail
    E/BaseActivity: Skin failed: com.poweramp.v3.sampleskin, resetting to default
  2. If I try to open Poweramp, go to the skin settings, choose one of the sample skins (with all its options turned off), and go back, I get this:

    E/BaseActivity: android.view.InflateException: File: android:layout/screen_title -> Binary XML file line #32: Failed to resolve attribute at index 1: TypedValue{t=0x2/d=0x101005a a=-1}
    Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 1: TypedValue{t=0x2/d=0x101005a a=-1}
        at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:771)
        at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:7555)
        at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:7746)
        at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1976)
        at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1874)
        at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1872)
        at qa.l1l1(":1013)
        at qa.l1l1(":956)
        at sm.l1l1(":333)
        at qa.l1l1(":884)
        at sm.l1l1(":278)
        at qa.inflate(":403)
        at qa.inflate(":352)
        at com.android.internal.policy.DecorView.onResourcesLoaded(DecorView.java:1933)
        at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:2586)
        at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2659)
        at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:409)
        at android.app.Activity.setContentView(Activity.java:2674)
        at com.maxmpz.audioplayer.BaseActivity.l1l1(":551)
        at com.maxmpz.audioplayer.BaseActivity.setContentView(":546)
        at com.maxmpz.audioplayer.ListActivity.onCreate(":105)
        at android.app.Activity.performCreate(Activity.java:7054)
        at android.app.Activity.performCreate(Activity.java:7045)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2732)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2857)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1590)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6499)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
    E/BaseActivity: handleLayoutFailure=>resetSkinOnFail
    E/BaseActivity: Skin failed: com.poweramp.v3.sampleskin, resetting to default
  3. If I go to the skin activity, go to "Open Theme Settings", chose the sample skin and go back, I get this:

    E/BaseActivity: java.lang.RuntimeException: bad themeId for me=com.maxmpz.audioplayer.StartupActivity@73e405d
        at com.maxmpz.audioplayer.StartupActivity.l1l1(":91)
        at com.maxmpz.widget.BasePowerWidgetActivity.onApplyThemeResource(":198)
        at android.view.ContextThemeWrapper.initializeTheme(ContextThemeWrapper.java:198)
        at android.view.ContextThemeWrapper.setTheme(ContextThemeWrapper.java:140)
        at android.app.Activity.setTheme(Activity.java:4300)
        at com.maxmpz.widget.BasePowerWidgetActivity.setTheme(":190)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2725)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2857)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1590)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6499)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
    E/BaseActivity: handleLayoutFailure=>resetSkinOnFail
    E/BaseActivity: Skin failed: com.poweramp.v3.sampleskin, resetting to default

I'm using build 799, running on my device with Android 8.1

maxmpz commented 6 years ago

You're probably on Android plugin 3.2+. If so, please update to https://github.com/maxmpz/powerampapi/commit/d375a5e07a72f27834d5fe49c0931638a3c13a6a

ghost commented 6 years ago

I am on master, so the changes in the commit you linked are there. Oh, and yes, I'm using the 3.2 plugin.

maxmpz commented 6 years ago

I don't think I can reproduce this issue on Android Studio 3.2 with latest updates. I would recommend using Android Studio => File => Invalidate Caches / Restart + Full clean rebuild

maxmpz commented 6 years ago

Skin sample project updated to android plugin 3.2.1 and built with latest available stable Android studio / gradle / sdk / plugin OK.

stuxo commented 6 years ago

Still happening for me using latest commit and the same configuration as you stated above. I'm also using the Poweramp-rc-build-799-uni apk.

2018-10-19 09:20:17.153 541-541/? E/BaseActivity: android.view.InflateException: File: com.maxmpz.audioplayer:layout/activity_list_fast -> Binary XML file line #53: Binary XML file line #53: You must supply a layout_width attribute.
    Caused by: java.lang.UnsupportedOperationException: Binary XML file line #53: You must supply a layout_width attribute.
        at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:775)
        at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:7606)
        at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:7798)
        at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:439)
        at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:370)
        at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:368)
        at qa.l1l1(":1013)
        at qa.l1l1(":846)
        at sm.l1l1(":278)
        at qa.inflate(":403)
        at qa.inflate(":352)
        at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:444)
        at android.app.Activity.setContentView(Activity.java:2661)
        at com.maxmpz.audioplayer.BaseActivity.l1l1(":551)
        at com.maxmpz.audioplayer.BaseActivity.setContentView(":546)
        at com.maxmpz.audioplayer.ListActivity.onCreate(":105)
        at android.app.Activity.performCreate(Activity.java:6982)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2811)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2933)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1612)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6710)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
2018-10-19 09:20:17.153 541-541/? E/BaseActivity: handleLayoutFailure=>resetSkinOnFail
2018-10-19 09:20:17.154 541-541/? E/BaseActivity: Skin failed: com.poweramp.v3.sampleskin, resetting to default
maxmpz commented 6 years ago

Basically, something prevents your environment to build proper APK (no resources included).It looks like invalid AAPT2 result due to either old or some beta Android SDK Build tools.

Do you build against that 799 build and path to 799 Poweramp apk in app build.gradle is updated? aaptOptions { additionalParameters "--package-id", "0x80", "-I", "PATH TO YOUR POWERAMP APK HERE" }

My current aapt2 is ver 3.2.1-4818971

ghost commented 6 years ago

Which is odd, because if I put a path that doesn't exists, the build fails, as you can see:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
  Output:  W/ziparchive(  548): Unable to open 'C:\Users\felbottrel\audioplayer2.apk': No such file or directory
  error: failed to open APK: I/O error.

  Command: C:\Users\felbottrel\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\bb9647348f8bf26b977d64e72ce37267\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
          C:\Users\felbottrel\AppData\Local\Android\Sdk\platforms\android-28\android.jar\
          --manifest\
          C:\Users\felbottrel\Code\powerampapi\poweramp_skin_sdk\poweramp_skin_sample\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
          -o\
          C:\Users\felbottrel\Code\powerampapi\poweramp_skin_sdk\poweramp_skin_sample\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
          -R\
          @C:\Users\felbottrel\Code\powerampapi\poweramp_skin_sdk\poweramp_skin_sample\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
          --auto-add-overlay\
          --java\
          C:\Users\felbottrel\Code\powerampapi\poweramp_skin_sdk\poweramp_skin_sample\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
          --custom-package\
          com.poweramp.v3.sampleskin\
          -0\
          apk\
          --package-id\
          0x80\
          -I\
          C:\Users\felbottrel\audioplayer2.apk\
          --no-version-vectors
  Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

If I put the correct path it builds successfully, so theoretically it should be linked correctly, right?

garzon-it commented 6 years ago

Hi there. Im having exactly the same problem as felbottrel. Have the correct path to the apk. I'm using Android Studio 3.2.1

maxmpz commented 6 years ago

That shouldn't be a empty path (comment evaluated test in >< as tag and hid it). Path to recent Poweramp APK should be there.

maxmpz commented 6 years ago

andres, are you on windows too?

garzon-it commented 6 years ago

No, im on Mac OS 10.13.6

garzon-it commented 6 years ago

Hi there.. Any update on this?

simplyrains commented 6 years ago

You may need to turn off the Android Studio's "Instant Run" feature. (Prefs > Build, Execution, Deployment > Instant Run)

I turned off mine, invalidated caches, and it worked.

garzon-it commented 6 years ago

@simplyrains Thank you!!! It works!

maxmpz commented 6 years ago

Thanks for the hint.