flet-dev / serious-python

Python runtime for Flutter apps
Apache License 2.0
211 stars 22 forks source link

Error while dexing #95

Closed SirDank closed 5 months ago

SirDank commented 6 months ago

I have followed the setup process from the readme

cmd used:

dart run serious_python:main package --asset assets/python.zip python --mobile

error log on deploy:

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings
ERROR:D:\BigBoi\Github\flutter_application_1\build\path_provider_android\intermediates\runtime_library_classes_jar\debug\classes.jar: D8: java.lang.NullPointerException
D:\BigBoi\Android\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-strip.exe: error: 'D:\BigBoi\Github\flutter_application_1\build\serious_python_android\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libpythonbundle.so': The file was not recognized as a valid object file

D:\BigBoi\Android\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-strip.exe: error: 'D:\BigBoi\Github\flutter_application_1\build\serious_python_android\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libpythonbundle.so': The file was not recognized as a valid object file

D:\BigBoi\Android\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-strip.exe: error: 'D:\BigBoi\Github\flutter_application_1\build\serious_python_android\intermediates\merged_native_libs\debug\out\lib\x86_64\libpythonbundle.so': The file was not recognized as a valid object file

D:\BigBoi\Android\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-strip.exe: error: 'D:\BigBoi\Github\flutter_application_1\build\app\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libpythonbundle.so': The file was not recognized as a valid object file

D:\BigBoi\Android\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-strip.exe: error: 'D:\BigBoi\Github\flutter_application_1\build\app\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libpythonbundle.so': The file was not recognized as a valid object file

D:\BigBoi\Android\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-strip.exe: error: 'D:\BigBoi\Github\flutter_application_1\build\app\intermediates\merged_native_libs\debug\out\lib\x86_64\libpythonbundle.so': The file was not recognized as a valid object file

warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeLibDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform classes.jar (project :path_provider_android) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: D:\BigBoi\Github\flutter_application_1\build\path_provider_android\intermediates\runtime_library_classes_jar\debug\classes.jar.
         > Error while dexing.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 51s
Error: Gradle task assembleDebug failed with exit code 1

Exited (1).

pubspec.yaml:

name: flutter_application_1
description: "A new Flutter project."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
  sdk: '>=3.4.1 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.6
  serious_python: ^0.7.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^4.0.0
  flutter_launcher_icons: ^0.13.1

flutter:
  uses-material-design: true
  assets:
    - assets/python.zip

flutter_launcher_icons:
  ios: true
  android: true
  adaptive_icon_background: "#000000"
  adaptive_icon_foreground: "images/app.png"
  image_path: "images/app.png"

main.dart:

import 'package:flutter/material.dart';
import 'dart:math' show Random;
import 'theme.dart';
import 'package:serious_python/serious_python.dart';
...
void startPython() async {
  SeriousPython.run("assets/python.zip", appFileName: "main.py", sync: true);
}

void main() {
  startPython();
  runApp(MaterialApp(
    debugShowCheckedModeBanner: false,
    theme: AppTheme.getTheme(),
    initialRoute: '/',
    routes: {
      '/': (context) => const Home(),
      '/profile': (context) => const ProfilePage(),
    },
  ));
}

main.py

import time

while True:
    print("sleeping for 10s...")
    time.sleep(10)

default andoird/app/build.gradle

plugins {
    id "com.android.application"
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader("UTF-8") { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
    flutterVersionCode = "1"
}

def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
    flutterVersionName = "1.0"
}

android {
    namespace = "com.example.Dankware"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.example.Dankware"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdk = flutter.minSdkVersion
        targetSdk = flutter.targetSdkVersion
        versionCode = flutterVersionCode.toInteger()
        versionName = flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig = signingConfigs.debug
        }
    }
}

flutter {
    source = "../.."
}

default android/gradle.properties:

org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true

flutter doctor -v

[√] Flutter (Channel stable, 3.22.1, on Microsoft Windows [Version 10.0.22621.2428], locale en-US)
    • Flutter version 3.22.1 on channel stable at D:\BigBoi\.flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (2 weeks ago), 2024-05-22
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at D:\BigBoi\Android
    • Platform android-34, build-tools 34.0.0
    • ANDROID_SDK_ROOT = D:\BigBoi\Android
    • Java binary at: C:\Program Files\Eclipse Adoptium\jdk-22.0.1.8-hotspot\bin\java
    • Java version OpenJDK Runtime Environment Temurin-22.0.1+8 (build 22.0.1+8)