Chaquopy How can I import pattern library? - java

I would like to import pattern library of python.
The build gradle (app) is like below.
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.chaquo.python'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.chaquopy"
python{
pip{
install "pattern"
}
}
sourceSets{
main{
python{
srcDirs = ["src/main/python"]
}
}
}
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
// Here is local python.exe folder.
python{
buildPython "C:/Users/xxxx/AppData/Local/Programs/Python/Python38/python.exe"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
Sync task finished successfully,
but it failed when I build the project, because of the failure to install mysqlclient.
Can I import pattern library using Chaquopy?
I'll appreciate your help.

It looks like Pattern doesn't actually require mysqlclient: in fact, it defaults to using SQLite. So you can modify it to remove the requirement:
Download the sdist from https://pypi.org/project/Pattern/#files.
Extract it.
Edit Pattern-3.6/setup.py to remove the "mysqlclient" requirement.
Create a .zip or .tar.gz file from the modified Pattern-3.6 directory.
Install this file by its filename, as shown in the Chaquopy documentation.

Related

How to integrate allure report with gradle, junit4 and espresso?

I am trying to generate allure report for android tests, but when I run command .\gradlew clean test, only testcases in test folder are there in the report. there are no tests from androidTest package. is there something wrong in the command or the build.gradle file. I am new to this, not able to figure it out.
I am using Android studio. Attaching build.gradle script.
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "io.qameta.allure.gradle.allure:allure-plugin:2.11.2"
}
}
plugins {
id 'com.android.application'
id "io.qameta.allure" version "2.11.2"
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.tabbedactivity"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "io.qameta.allure.espresso.AllureAndroidRunner
}
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
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
implementation 'com.google.guava:guava:30.1.1-jre'
implementation 'org.seleniumhq.selenium:selenium-java:4.4.0'
implementation 'io.github.bonigarcia:webdrivermanager:5.3.0'
implementation 'io.qameta.allure:allure-junit4:2.19.0'
}
tasks.withType(Test) {
exclude '**/calltest/Summary.class'
}
Attached the copy of build.gradle file.

The application does not work after publishing in the Google market. R8

I can’t understand why the code stopped working correctly after being published in the Google market in the release branch.
Step 1. Problem of the following character: 1. Turn on "minifyEnabled true", configure the proguard-rules.pro file. I write there the names of classes whose code does not need to be changed (-keep public class myClassName ...)
I check all this on the local computer - everything works (As you can see, the same settings for both release and debug)
I upload to the Google market - a branch of internal testing. Does not work.
Step 2. Turn off "minifyEnabled false".
I upload the code to the Google market in the internal testing branch. Surprisingly, everything works.
Ok, I'm trying to copy the current version from the internal branch to the release branch.
And, after the publication, this version of the application does not work again.
First, I have "minifyEnabled" turned off, but the app behaves like it's enabled. The application also starts to crumble in other places because of the encrypted variables, nonsense is passed to my functions and because of this they break.
Although I also have a "proguard-rules.pro" file with the rules configured correctly.
Step 3. I repeated step 2, only uploaded directly to the release branch, everything is exactly the same. Doesn't want to work.
Files:
plugins {
id 'com.android.application'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
// Apply the Crashlytics Gradle plugin
apply plugin: 'com.google.firebase.crashlytics'
repositories {
mavenCentral()
}
android {
compileSdkVersion 33
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.my.app"
minSdkVersion 23
targetSdkVersion 33
versionCode 40
versionName "1.0"
setProperty("archivesBaseName", applicationId + "-v" + versionCode + "(" + versionName + ")")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
packagingOptions {
resources {
excludes += ['META-INF/DEPENDENCIES', 'META-INF/LICENSE', 'META-INF/LICENSE.txt', 'META-INF/license.txt', 'META-INF/NOTICE', 'META-INF/NOTICE.txt', 'META-INF/notice.txt', 'META-INF/ASL2.0']
}
}
namespace 'com.my.app'
}
dependencies {
//firebase auth
implementation platform('com.google.firebase:firebase-bom:29.1.0')
implementation 'com.google.firebase:firebase-auth:21.1.0'
// google
implementation 'com.google.android.play:core:1.10.3'
implementation 'com.google.android.gms:play-services-games:23.0.0'
implementation 'com.google.android.gms:play-services-auth:20.3.0'
//firebase-crashlytics
implementation 'com.google.firebase:firebase-crashlytics:18.3.1'
implementation 'com.google.firebase:firebase-analytics:21.2.0'
//google billing
implementation "com.android.billingclient:billing:5.0.0"
implementation "com.android.volley:volley:1.2.1"
//default
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'com.nex3z:flow-layout:1.3.3'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'org.jetbrains:annotations:16.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//JUnit 4 Test
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "androidx.lifecycle:lifecycle-viewmodel:2.5.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
}
next file:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
classpath 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1'
}
}
allprojects {
repositories {
mavenCentral()
google()
}
task clean(type: Delete) {
delete rootProject.buildDir
}
proguard-rules.pro file:
-keep public class myClassName

Project can't compile after adding admob library

When I add adomb library to my project apps stop working without showing any errurs on android studio. See here.
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.ozayd.azkar"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.13.2'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
It's maybe conflict version between your app and admob.
try upgrade admob version :
//with appcompat & material:
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.gms:play-services-ads:21.0.0'
implementation 'com.google.android.play:core:1.10.3'
then sync project again.
If it don't work, try add resolutionStrategy in gradle file:
android {
defaultConfig {
configurations.all {
resolutionStrategy {
force 'androidx.appcompat:appcompat:1.5.1'
force 'com.google.android.material:material:1.6.1'
}
}
}
}
then clean project and re sync

Gradle sync Problem : Could not GET "kotlin-stdlib-jdk8-1.4.30.pom"

I am getting the following error in the Android Studio when "Gradle sync" is on action:
Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.4.30/kotlin-stdlib-jdk8-1.4.30.pom'. Received status code 403 from server: Forbidden
Disable Gradle 'offline mode' and sync project
It downloads few files then stuck on the same filekotlin-stdlib-jdk8-1.4.30.pom and show the error above.
I have tried several solutions like here and here and none of them realy solve the problem.
And since I am only using Java why the Android studio should care about kotlin ,is there any thing i can do to avoid dealing with Kotlin?
this is the gradle>build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
//classpath "com.android.tools.build:gradle:4.1.3"
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and this is the app>src>build.gradle file:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.myapplication_10"
minSdkVersion 29
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:4.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
403 Forbidden usually means you're connecting from a country under US sanctions (Iran for example). Try to clean project, clear Gradle cache, quit android studio, connect to a VPN to change the IP of your computer, open studio and sync/run. Also some services like Shecan or Begzar might help.

Android Studio 3.0 Unresolved reference: SupportedLanguages for AIConfiguration class in Dialogflow(api.ai)

I am building a chatbot Android app in Kotlin, through queries to a Dialogflow agent. I am using the Dialogflow android client github repository Readme and the sample app provided in that repository as the basis to build the app. As referenced in the above sources, java code for AIConfiguration.SupportedLanguages works fine:
import ai.api.android.AIConfiguration;
.....
private void initService(final LanguageConfig selectedLanguage) {
final AIConfiguration.SupportedLanguages lang = AIConfiguration.SupportedLanguages.fromLanguageTag(selectedLanguage.getLanguageCode());
.....
You can find the full usage of this here.
When I am implementing this in Kotlin:
import ai.api.android.AIConfiguration
....
private fun initService() {
//final AIConfiguration.SupportedLanguages lang = AIConfiguration.SupportedLanguages.fromLanguageTag(selectedLanguage.getLanguageCode());
val config = AIConfiguration(CLIENT_ACCESS_TOKEN,
AIConfiguration.SupportedLanguages.EnglishGB,
AIConfiguration.RecognitionEngine.System)
....
in Android 3.0 I am getting a gradle error of "Unresolved reference: SupportedLanguages" for AIConfiguration.SupportedLanguages. AIConfiguration.RecognitionEngine is resolving just fine. Why is this problem happening? What solution/work-around can I implement?
My higher level build.gradle file:
apply plugin: 'com.android.feature'
android {
compileSdkVersion 27
baseFeature true
defaultConfig {
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '27.0.1'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
api 'com.android.support:appcompat-v7:27.0.0'
api 'com.android.support:design:27.0.0'
api 'com.android.support.constraint:constraint-layout:1.0.2'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'ai.api:sdk:2.0.7#aar'
compile 'ai.api:libai:1.6.12'
//compile project(':ailib')
application project(':app')
feature project(':chatbot')
}
My module build.gradle file:
apply plugin: 'com.android.feature'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '27.0.1'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
implementation project(':base')
//add the google gson library
compile 'com.google.code.gson:gson:2.8.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
One workaround I found that is working is to use ai.api.AIConfiguration.SupportedLanguages which is resolving instead of ai.api.android.AIConfiguration.SupportedLanguages which is not resolving in kotlin in Android Studio 3.0 as mentioned in the question.
However, calling ai.api.android.AIConfiguration.SupportedLanguages works just fine in Java code, in which case it is resolving correctly in Android Studio 3.0. Since ai.api.android.AIConfiguration implements ai.api.AIConfiguration, why this issue is arising is puzzling!
Just use this line instead of previous -
ai.api.AIConfiguration.SupportedLanguages.English,

Categories