Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service_library lacks mActivity support #2350

Closed
C1em opened this issue Nov 5, 2020 · 0 comments
Closed

service_library lacks mActivity support #2350

C1em opened this issue Nov 5, 2020 · 0 comments

Comments

@C1em
Copy link

C1em commented Nov 5, 2020

Versions

  • Python: 3.7.0
  • OS: macOS 10.14.5
  • Kivy: 1.11.1
  • Cython: 0.28.2
  • OpenJDK: 8u272b10

Description

I tried to build an android library (.aar) using the service_library bootstrap. But an error occurred at the end of the build with gradle.

Command:

p4a aar --private $HOME/Projects/p4aTest/src --package=org.example.myapp --name "My application" --version 0.1 --requirements=python3,websockets --sdk-dir /usr/local/Caskroom/android-sdk/4333796/ --ndk-dir /usr/local/Caskroom/android-ndk/21/android-ndk-r21/ --bootstrap service_library

Logs

  RAN: $HOME/.python-for-android/dists/unnamed_dist_1__armeabi-v7a/gradlew assembleDebug

  STDOUT:

> Task :compileDebugJavaWithJavac FAILED
$HOME/.python-for-android/dists/unnamed_dist_1__armeabi-v7a/src/main/java/org/renpy/android/Hardware.java:162: error: cannot find symbol
        PythonActivity.mActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
                      ^
  symbol:   variable mActivity
  location: class PythonActivity
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

Workaround

I made a temporary fix in the python-for-android/pythonforandroid/bootstraps/service_library/build/src/main/java/org/kivy/android/PythonActivity.java by adding some lines:

package org.kivy.android;

import android.os.Bundle;
import android.app.Activity;

// Required by PythonService class
public class PythonActivity extends Activity {

    public static PythonActivity mActivity = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.mActivity = this;
    }
}

there is no more compilation error but I haven't yet tried the .aar to check if everything works fine.

@C1em C1em closed this as completed Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant