jonbhanson / flutter_native_splash

Automatically generates native code for adding splash screens in Android and iOS. Customize with specific platform, background color and splash image.
https://pub.dev/packages/flutter_native_splash
MIT License
1.28k stars 200 forks source link

pub finished with exit code 255 #3

Closed lubi888 closed 4 years ago

lubi888 commented 4 years ago

Hi,

Just saw your link on reddit and wanted to give it a try.

Here's the error code: `flutter pub pub run flutter_native_splash:create [Android] Creating splash images [Android] Updating launch_background.xml with splash image path [iOS] Creating splash images [iOS] Updating LaunchScreen.storyboard with width, height and color Unhandled exception: RangeError: Invalid value: Only valid value is 0: -1

0 List.insert (dart:core-patch/growable_array.dart:11:7)

1 _updateLaunchBackgroundFileWithImagePath (package:flutter_native_splash/android.dart:104:11)

#2 _applyLaunchBackgroundXml (package:flutter_native_splash/android.dart:77:12) #3 createSplash (package:flutter_native_splash/android.dart:26:9) #4 createSplash (package:flutter_native_splash/flutter_native_splash.dart:18:5) #5 main (file:///C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_splash-0.1.4/bin/create.dart:5:3) #6 _startIsolate. (dart:isolate-patch/isolate_patch.dart:299:32) #7 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12) pub finished with exit code 255`
lubi888 commented 4 years ago

I can add some details as it looks like most of the programming worked. I'll list what was changed here. I'm using Win 10.

There are 5 new resources in app/src/main/res alongside the normal 'mipmap-hdpi', etc. and these are 'drawable-hdpi', 'drawable-mdpi' etc.

drawable\launch_background.xml has been deleted res\values\colors.xml has been created and is clean. res\values\styles.xml has been deleted and not written to. This is an error.

ios\Runner\AppDelegate.m has been deleted. Another error? ios\Runner\Info.plist has been deleted. ? it looks like all the assets of 2x and 3 x were added correctly to ios

ok, let me know if I can help in any way.

henriquearthur commented 4 years ago

Thank you for reporting this.

We are dealing with two different issues here.

First issue It seems like an error occurred when the package was trying to update launch_background.xml. That can happen if the package can't find the line containing android:src="@drawable/splash", which comes by default on a new Flutter project, or for some reason it could not read the lines on that file.

Can you provide the content of app/src/main/res/drawable/launch_background.xml so I can investigate this?

Second issue This issue is related to files being deleted or created empty. This package previously ran every non-depend step of creating a splash screen asynchronously. That means, in your case, that the steps below were running at the same time.

[Android] Updating launch_background.xml with splash image path
[iOS] Creating splash images
[iOS] Updating LaunchScreen.storyboard with width, height and color

If any of these steps throws an Exception (which was exactly what happened) the package stops running, even if any others steps are not finished yet. This is not ideal because it can create empty files or update by half.

I fixed this issue on version 0.1.5 by making every step run synchronously. If some step throws an Exception, it will not cause side effects.

Please update the package before running it again.

htsnet commented 4 years ago

flutter pub pub run flutter_native_splash:create [Android] Creating splash images [Android] Updating launch_background.xml with splash image path [Android] Updating colors.xml with color for splash screen background [Android] Updating styles.xml with full screen mode setting Unhandled exception: ERROR [flutter_native_splash] CantFindMainActivityPath Not able to determinate MainActivity path. Maybe the problem is your package path OR your AndroidManifest.xml 'package' attribute on manifest.

0 _javaOrKotlin (package:flutter_native_splash/android.dart:289:5)

#1 _applyMainActivityUpdate (package:flutter_native_splash/android.dart:263:33) #2 createSplash (package:flutter_native_splash/android.dart:33:9) #3 createSplash (package:flutter_native_splash/flutter_native_splash.dart:18:11) #4 main (file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_splash-0.1.5/bin/create.dart:5:3) #5 _startIsolate. (dart:isolate-patch/isolate_patch.dart:303:32) #6 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12) pub finished with exit code 255
henriquearthur commented 4 years ago

@htsnet the package couldn't find MainActivity file to update. Are you using Java or Kotlin?

If it is Java: Can you confirm your MainActivity.java is located at android/app/src/main/java/com/example/YOUR_PACKAGE/MainActivity.java?

If it is Kotlin: Can you confirm your MainActivity.kt is located at android/app/src/main/kotlin/com/example/YOUR_PACKAGE/MainActivity.kt?

htsnet commented 4 years ago

@henriquearthur MainActivity.java is at ...\SemContato\android\app\src\main\java\br\com\htsnet\sem_contato\MainActivity.java

I don´t have /kotlin folder

henriquearthur commented 4 years ago

@htsnet thank you for reporting. The package could not find MainActivity because of custom package name. Version 0.1.6 fixes the problem. Update the package and run again.

This is not related to the issue by @lubi888.

htsnet commented 4 years ago

@henriquearthur It works now. Thank you! Great job.

lubi888 commented 4 years ago

Hi Henrique,

Having fun publishing?!

Here’s the contents of drawable.xml that was deleted yesterday by the release version.

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>

I created this flutter app recently using Android Studio because I had to upgrade my whole flutter project to AndroidX. I didn’t use the ‘flutter create’ command to create this app.

I have check this again and just created a new flutter app using Android and the output is the same as what I already have and is shown above. Thus, there is no line you referred to android:src="@drawable/splash

I have just created a sample app using ‘flutter create’ and the output is the same as using Android Studio.

Ok, I’ve just installed your updated code and here are the results for 0.1.6

flutter pub pub run flutter_native_splash:create

[Android] Creating splash images
[Android] Updating launch_background.xml with splash image path
[Android] No colors.xml file found in your Android project
[Android] Creating colors.xml file and adding it to your Android project
[Android] Updating styles.xml with full screen mode setting
[iOS] Creating splash images
[iOS] Updating LaunchScreen.storyboard with width, height and color
[iOS] Updating Info.plist for status bar hidden/visible
[iOS] Updating AppDelegate for status bar hidden/visible

The process took about 30 seconds to create all the files correctly. The good news is that all is working now :-) Here’s a shot from GitHub desktop that shows how launch_background.xml was added to.

Annotation 2019-08-27 122846

Should I say ‘merci’ or ‘obrigado’ Henrique? Thanks. Plugin is working now and I find it easier to use than the other splash plugins.

henriquearthur commented 4 years ago

@lubi888 my apologies. I said that:

android:src="@drawable/splash", which comes by default on a new Flutter project

But that's not true. That line is added by flutter_nativesplash to reference the splash image. (probably said that confusing with iOS)_. Not sure why the package couldn't read the launch_background.xml lines causing the first error.

Anyway, glad it's working for you.

It's actually "obrigado" as I am from Brazil. First publish so far it's actually a very good experience!

Thanks. :)

thisisddzin commented 4 years ago

In my case the problem was that I had changed the package name com.example for com.mydomain and forget of change already the android path name.

If that is you case too try change here like that: android/app/src/main/com/<change here 'example' for your domain>/...

joaovirgili commented 4 years ago

My package: com.geekbusinesslab.PepsRelatorios. My MainActivity path is android/app/src/main/kotlin/com/example/pepsfield_relatorios_app/MainActivity.kt

what should i do?

corymalcolmtaylor commented 4 years ago

Have you tried renaming the folder to android/app/src/main/kotlin/com/geekbusinesslab/pepsfield_relatorios_app/MainActivity.kt

I dd that and now the create command completes and the launch image works on my android emulator. However it still does not show up on my ios simulator (iphone SE 2nd gen). I just see a black screen until my app shows up.

Flutter 1.17.0 • channel beta • https://github.com/flutter/flutter.git Framework • revision d3ed9ec945 (2 weeks ago) • 2020-04-06 14:07:34 -0700 Engine • revision c9506cb8e9 Tools • Dart 2.8.0 (build 2.8.0-dev.18.0 eea9717938)

I can't get a launch screen to work on the ios sim by other any other methods (Xcode) either so it is probably not a problem with this package.

kunjmehta-123 commented 3 years ago

C:\flutterApps\newsplash>flutter pub pub run flutter_native_splash:create [Android] Creating splash images [Android] Updating launch_background.xml with splash image path [Android] No colors.xml file found in your Android project [Android] Creating colors.xml file and adding it to your Android project [Android] Updating styles.xml with full screen mode setting Unhandled exception: FormatException: Invalid radix-16 number (at character 1) “4 ^

0 int._throwFormatException (dart:core-patch/integers_patch.dart:131:5)

1 int._parseRadix (dart:core-patch/integers_patch.dart:142:16)

2 int._parse (dart:core-patch/integers_patch.dart:100:12)

3 int.parse (dart:core-patch/integers_patch.dart:63:12)

4 new HexColor (package:color/hex_color.dart:21:17)

5 _generatePrimaryColorDarkFromColor (package:flutter_native_splash/android.dart:48:45)

6 createSplash (package:flutter_native_splash/android.dart:42:34)

#7 createSplash (package:flutter_native_splash/flutter_native_splash.dart:20:11) #8 main (file:///C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_native_splash-0.1.9/bin/create.dart:5:3) #9 _startIsolate. (dart:isolate-patch/isolate_patch.dart:299:32) #10 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12) pub finished with exit code 255 This is the error I'm getting. Anything I can do about this?
lukepighetti commented 3 years ago

My package name is twic.app, how can I proceed?

Edit: ended up doing android/app/src/main/kotlin/twic/app/MainActivity.kt