【问题标题】:flutter cannot run apk on real device颤振无法在真实设备上运行 apk
【发布时间】:2021-05-10 15:02:38
【问题描述】:

我在flutter中创建了一个demo应用,在Android设备上构建后尝试运行应用,APK无法安装,Android设备给了(不幸的是,demo有停了。) Flutter 2.0.6 • 频道稳定 Flutter 医生 • 未发现任何问题! 颤动运行-v

 - [ +112 ms] E/AndroidRuntime(26009): FATAL EXCEPTION: main
[   +2 ms] E/AndroidRuntime(26009): Process: com.example.demo, PID: 26009
[   +2 ms] E/AndroidRuntime(26009): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.demo/com.example.demo.MainActivity}:
android.content.res.Resources$NotFoundException: File res/drawable-v21/launch_background.xml from drawable resource ID #0x7f040000
[   +3 ms] E/AndroidRuntime(26009):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2656)
[   +3 ms] E/AndroidRuntime(26009):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2721)
[   +1 ms] E/AndroidRuntime(26009):     at android.app.ActivityThread.access$900(ActivityThread.java:168)
[   +1 ms] E/AndroidRuntime(26009):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
[   +1 ms] E/AndroidRuntime(26009):     at android.os.Handler.dispatchMessage(Handler.java:102)
[   +1 ms] E/AndroidRuntime(26009):     at android.os.Looper.loop(Looper.java:135)
[   +1 ms] E/AndroidRuntime(26009):     at android.app.ActivityThread.main(ActivityThread.java:5753)
[   +1 ms] E/AndroidRuntime(26009):     at java.lang.reflect.Method.invoke(Native Method)
[   +7 ms] E/AndroidRuntime(26009):     at java.lang.reflect.Method.invoke(Method.java:372)
[   +1 ms] E/AndroidRuntime(26009):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
[   +1 ms] E/AndroidRuntime(26009):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
[   +1 ms] E/AndroidRuntime(26009): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-v21/launch_background.xml from drawable resource ID
#0x7f040000
[   +1 ms] E/AndroidRuntime(26009):     at android.content.res.Resources.loadDrawableForCookie(Resources.java:2890)
[   +1 ms] E/AndroidRuntime(26009):     at android.content.res.Resources.loadDrawable(Resources.java:2765)
[   +4 ms] E/AndroidRuntime(26009):     at android.content.res.Resources.getDrawable(Resources.java:1012)
[   +5 ms] E/AndroidRuntime(26009):     at android.content.res.Resources.getDrawable(Resources.java:978)
[   +2 ms] E/AndroidRuntime(26009):     at io.flutter.embedding.android.FlutterActivity.getSplashScreenFromManifest(FlutterActivity.java:493)
[   +1 ms] E/AndroidRuntime(26009):     at io.flutter.embedding.android.FlutterActivity.provideSplashScreen(FlutterActivity.java:469)
[   +1 ms] E/AndroidRuntime(26009):     at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onCreateView(FlutterActivityAndFragmentDelegate.java:301)
[   +4 ms] E/AndroidRuntime(26009):     at io.flutter.embedding.android.FlutterActivity.createFlutterView(FlutterActivity.java:518)
[   +1 ms] E/AndroidRuntime(26009):     at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:415)
[   +2 ms] E/AndroidRuntime(26009):     at android.app.Activity.performCreate(Activity.java:6112)
[   +2 ms] E/AndroidRuntime(26009):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1117)
[   +1 ms] E/AndroidRuntime(26009):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2609)
[   +2 ms] E/AndroidRuntime(26009):     ... 10 more
[   +1 ms] E/AndroidRuntime(26009): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #4: <item> tag requires a 'drawable' attribute or child tag
defining a drawable
[   +6 ms] E/AndroidRuntime(26009):     at android.graphics.drawable.LayerDrawable.inflateLayers(LayerDrawable.java:202)
[   +1 ms] E/AndroidRuntime(26009):     at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:147)
[   +1 ms] E/AndroidRuntime(26009):     at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1095)
[   +1 ms] E/AndroidRuntime(26009):     at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1017)
[   +1 ms] E/AndroidRuntime(26009):     at android.content.res.Resources.loadDrawableForCookie(Resources.java:2880)
[   +1 ms] E/AndroidRuntime(26009):     ... 21 more

....

[  +11 ms] Installing build\app\outputs\flutter-apk\app.apk...
[   +4 ms] executing: C:\Users\Adi KANSO\AppData\Local\Android\sdk\platform-tools\adb.exe -s ea88b045 install -t -r C:\demo\build\app\outputs\flutter-apk\app.apk
[+35426 ms] Performing Push Install
                     C:\demo\build\app\outputs\flutter-apk\app.apk: 1 file pushed, 0 skipped. 5.5 MB/s (50970196 bytes in 8.905s)
                        pkg: /data/local/tmp/app.apk
                     Success
[   +4 ms] Installing build\app\outputs\flutter-apk\app.apk... (completed in 35.4s)
[   +6 ms] executing: C:\Users\Adi KANSO\AppData\Local\Android\sdk\platform-tools\adb.exe -s ea88b045 shell echo -n 224dbc5d94c46ece2ee3d1ef273b59c4eac1c401 >
/data/local/tmp/sky.com.example.demo.sha1
[  +67 ms] executing: C:\Users\Adi KANSO\AppData\Local\Android\sdk\platform-tools\adb.exe -s ea88b045 shell -x logcat -v time -t 1
[ +153 ms] --------- beginning of main
                    05-10 17:45:05.756 E/lights  (  995): write_int failed to open -1
[  +23 ms] executing: C:\Users\Adi KANSO\AppData\Local\Android\sdk\platform-tools\adb.exe -s ea88b045 shell am start -a android.intent.action.RUN -f 0x20000000 --ez
enable-background-compilation true --ez enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points true
com.example.demo/com.example.demo.MainActivity
[+1390 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.demo/.MainActivity (has extras) }
[   +6 ms] Waiting for observatory port to be available...
[  +19 ms] Observatory URL on device: http://127.0.0.1:34736/hleZMml4hFQ=/
[   +4 ms] executing: C:\Users\Adi KANSO\AppData\Local\Android\sdk\platform-tools\adb.exe -s ea88b045 forward tcp:0 tcp:34736
[  +48 ms] 60889
[   +1 ms] Forwarded host port 60889 to device port 34736 for Observatory
[  +10 ms] Caching compiled dill
[  +44 ms] Connecting to service protocol: http://127.0.0.1:60889/hleZMml4hFQ=/
[  +18 ms] Fail to connect to service protocol: http://127.0.0.1:60889/hleZMml4hFQ=/: HttpException: Connection closed before full header was received, uri =
http://127.0.0.1:60889/hleZMml4hFQ=/ws
[+1407 ms] Error connecting to the service protocol: failed to connect to http://127.0.0.1:60889/hleZMml4hFQ=/

请帮忙!!

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    请在清单文件中取消注释

    <meta-data
    android:name="io.flutter.embedding.android.SplashScreenDrawable"
    android:resource="@drawable/launch_background" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-26
      • 2021-12-16
      • 2019-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-08
      相关资源
      最近更新 更多