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

Couldn't build project in my local machine's android studio #268

Closed
ajaygalagali opened this issue Apr 8, 2021 · 15 comments
Closed

Couldn't build project in my local machine's android studio #268

ajaygalagali opened this issue Apr 8, 2021 · 15 comments

Comments

@ajaygalagali
Copy link

Getting this error

Could not resolve all dependencies for configuration ':app:debugAndroidTestCompileClasspath'.
Could not create task ':app:minifyReleaseWithR8'.
Cannot query the value of this provider because it has no value available.
@rkkr
Copy link
Owner

rkkr commented Apr 10, 2021

You probably messed something up. There is no AndroidTestconfiguration. Looks like you made a new project and put the source files in it.

I pulled the source code with git clone to have a clean repository. Started Android Studio 4.1.3 and opened the project. Clicked Build -> Make Project and it compiled:

9:21 AM	Executing tasks: [:app:assembleDebug] in project /home/rkr/Workspace/simple-keyboard

9:21 AM	Gradle build finished in 5 s 70 ms

app-debug.apk was placed in app/build/outputs/apk/debug.

@rkkr rkkr closed this as completed Apr 10, 2021
@ajaygalagali
Copy link
Author

I didn't make a new project. I cloned the repo by the "import by version control" option in Android Studio

@rkkr
Copy link
Owner

rkkr commented Apr 12, 2021

This just downlods the files. How did you open it?

@ajaygalagali
Copy link
Author

After importing, Android Studio opened this repo as Android project

@rkkr
Copy link
Owner

rkkr commented Apr 12, 2021

Just use git clone command line and the open as project.

@ajaygalagali
Copy link
Author

Let me try

@ajaygalagali
Copy link
Author

Hey, I followed the above steps but still, I am getting the same errors.

image

@rkkr
Copy link
Owner

rkkr commented Apr 12, 2021

Just tried by cloning inside Android Studio and in Windows. It just works:

image

Note the app node in Project structure. For you it shows simple-keyboard which means that it's opened "as a folder". You can try expanding it and I'm pretty sure it will just show the folder structure, not the app structure.

@ajaygalagali
Copy link
Author

Yes, It does show folder structure. How to make it show App structure?

@rkkr
Copy link
Owner

rkkr commented Apr 14, 2021

File -> Open -> Select "simple-keyboard" folder (must have android icon which means that it's a project).

@ajaygalagali
Copy link
Author

ajaygalagali commented Apr 14, 2021

In the previous screenshot, it had android icon for "simple-keyboard" folder when I opened.
It's not showing app structure because project build is failing

@rkkr
Copy link
Owner

rkkr commented Apr 17, 2021

Well I tested on a computer that didn't even have Android Studio installed and runs Windows. It just worked, so it's something messed up in your machine.

@Anonymous2716
Copy link

I built the app in my android phone in termux app. with gradle and without gradle . with gradle I had to do a little tweak. And without gradle it was super easy just javac , aapt and dx. Done .

@licaon-kter
Copy link
Contributor

@Anonymous2716 do share the exact steps, sounds nice :)

@Anonymous2716
Copy link

Anonymous2716 commented Aug 6, 2022

@licaon-kter install termux from fdroid if you haven't already https://github.com/termux/termux-app.
And then do the pkg update ; pkg upgrade as usual. Now you need to install couple of packages. . and they are openjdk-17 , aapt , dx .and also if you like apksigner then apksigner. Using the command

pkg install openjdk-17  git aapt  dx 

Now start building simple-keyboard.

Clone the repository in termux app :

git clone https:/github.com/rkkr/simple-keyboard

After cloning move to the simple-keyboard/app/src/main/ directory

Before you begin building here are two files you have to edit otherwise you will get errors. I got at least.

File 1:
./java/rkr/simplekeyboard/inputmethod/keyboard/KeyboardSwitcher.java
In Line 94 edit this
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { to this
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {

File 2

res/values-fr/strings.xml

In line 51 edit whatever strings inside it replace the strings. I replaced the strings to s
<string name="pref_enable_ime_switch">s</string>

I guess its just an encoding error.

Make sure you are in main directory
Now create R.java :

aapt package -f --generate-dependencies -J ./java/rkr/simplekeyboard/inputmethod -M AndroidManifest.xml --target-sdk-version 31 --replace-version -S res --version-code 2716 -I /data/data/com.termux/files/usr/share/aapt/android.jar --version-name "versionname"

And then compile the java code into classes.

javac -cp "$PREFIX"/share/java/android.jar --release 8 $(find . -name "*.java")

The .java files are now compiled in their own directories

Compile classes to Dex file :

dx --dex --output=classes.dex java

Create the apk file :

aapt package -f  --target-sdk-version 29 -M AndroidManifest.xml -S ./res  -F keyboard.apk -I /data/data/com.termux/files/usr/share/aapt/android.jar

Add the Dex fie to apk :

aapt add -v -f keyboard.apk classes.dex

There you go you have successfully built simple keyboard. Now you have to sign the apk file.
First answer on this thread

https://stackoverflow.com/questions/10930331/how-to-sign-an-already-compiled-apk

You can use this to sign the apk. Them move the apk to phones internal storage and install it.

For gradle build you have to follow this. Its more complicated than that. But worked.
termux/termux-packages#7227 (comment)

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

4 participants