I'm trying to use chaquopy in android studio to recognize audio from video and convert it to text, but when I call Python.getInstance() it overlines it in red. what can be the problem ?.
build.gradle(app)
plugins {
id 'com.google.gms.google-services'
//for chaquopy(python)
id 'com.android.application'
id 'com.chaquo.python'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.talhakara.uzaktanegitimbitirmeprojesi"
minSdk 16
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// for chaquopy(python)
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
python {
buildPython "C:/Users/enest/AppData/Local/Programs/Python/Python39/python.exe"
}
sourceSets {
main {
python.srcDir "src/main/python"
}
}
//
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
dataBinding true
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'com.google.android.gms:play-services-tasks:17.2.1'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation platform('com.google.firebase:firebase-bom:29.0.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.google.firebase:firebase-storage'
implementation 'com.google.firebase:firebase-core:20.1.0'
implementation 'com.google.firebase:firebase-messaging:23.0.0'
implementation 'com.google.firebase:firebase-appindexing:20.0.0'
implementation 'com.google.firebase:firebase-invites:17.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.google.firebase:firebase-firestore:24.0.1'
implementation 'com.firebaseui:firebase-ui-auth:4.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation ('org.jitsi.react:jitsi-meet-sdk:2.9.0') { transitive = true }
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
// implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
}
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
//chaquopy
maven { url "https://chaquo.com/maven" }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.google.gms:google-services:4.3.10'
//chaquopy
classpath "com.chaquo.python:gradle:10.0.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
my activity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityVideoConferenceBinding.inflate(getLayoutInflater());
View view = binding.getRoot();
setContentView(view);
//start python
if (! Python.isStarted()) {
Python.start(new AndroidPlatform(VideoConference.this));
}
Python py = new Python.getInstance(); // this line is red and
//it doesn't show any errors
binding.btnChooseVideo.setOnClickListener(view1 -> {
callChooseFromVideo();
});
}
error message
error: cannot find symbol
Python py = new Python.getInstance();
symbol: class getInstance
location: class Python
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details
Could it be a problem with gradle versions? because my gradle version 7.0.4 is showing 7.0 as the latest in chaquopy's docs. can it cause this problem and I am using 10.0.1 as the chaquopy version because android studio recommended it as the latest version. If these are a problem, which versions should I use?
The correct syntax is just Python.getInstance()
, not new Python.getInstance()
.