How do I build a TWA using #bubblewrap? - android

I am trying to build my TWA from a PWA, and I am running into an issue after running npx #bubblewrap/cli build:
Installing Android Build Tools. Please, read and accept the license agreement
build Installing Build Tools
Warning: Unknown argument --install
The licenses have all been accepted:
$ ./sdkmanager --licenses
Warning: File /home/user/.android/repositories.cfg could not be loaded.
All SDK package licenses accepted.
done
The sdkmanager I have on my local machine comes with everything installed out-of-the-box, which is why the install command cannot be found. You can only uninstall. So, I thought I could just comment out those lines of code from the local installation of #bubblewrap, but that did not stop this from executing.
Please, help! I am at a loss, and have no idea what to do! lol
I have all of the prerequesists installed. Here is my llama file:
{
"jdkPath":"/usr/lib/jvm/java-8-openjdk-amd64/jre",
"androidSdkPath":"/home/user/android"
}
This is the android-sdk I have installed: sdk-tools-linux-3859397.zip

It was just an outdated version of the SDK: https://developer.android.com/studio#command-tools
I needed to use the newest Linux distro version instead of an older one I downloaded from a command online that I thought would match Java 8 better...lol smh
It builds just fine now.
Thanks to anyone who attempted to answer!!!!

You can also generate your signed APK for your TWA on https://www.pwabuilder.com. We've been working with Google embedding their Bubblewrap tooling on our servers in a transparent way.
Read more: https://www.davrous.com/2020/02/07/publishing-your-pwa-in-the-play-store-in-a-couple-of-minutes-using-pwa-builder/
David

Related

Android Studio Mac Fresh install - error after error after error

Never really used a piece of software that threw so many errors. I installed and got all the errors below so tried a fresh install, following a reinstall process to remove it completely, even including the SDKs but installing it again threw the exact same errors. From what I read it should just work after the basic install?
First error on opening it for the first time:
unable to access android sdk add on list
Even though right after installing I added it and approved it in my firewall.
Then during install it says HAXM failed to install, and it gives a link to install it which is a page not found. Then I found in the SDK Manager under tools it shows Intel x86 Emulator Accelerator (HAXM installer) 7.3.2 - Installed. From what I read that means it IS installed?
I'm using MacOS High Sierra and supposedly going to System Preferences > Security & Privacy and opting to allow this particular app should fix it, but since I already have it set to allow any apps that clearly doesn't fix it for me.
Then I added the Flutter plugin, created the default app and launched it and I got the error:
* Error running Gradle:
ProcessException: Process "/Users/hasen/AndroidStudioProjects/testing_app/android/gradlew" exited abnormally:
Starting a Gradle Daemon (subsequent builds will be faster)
> Configure project :app
Checking the license for package Android SDK Build-Tools 28.0.3 in /usr/local/Cellar/android-sdk/24.4.1_1/licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 28 in /usr/local/Cellar/android-sdk/24.4.1_1/licenses
Warning: License for package Android SDK Platform 28 not accepted.
Picked up _JAVA_OPTIONS: -Xverify:none
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/hasen/AndroidStudioProjects/testing_app/android/build.gradle' line: 24
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-28 Android SDK Platform 28
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /usr/local/Cellar/android-sdk/24.4.1_1
* 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 13s
Command: /Users/hasen/AndroidStudioProjects/testing_app/android/gradlew app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
It says in this error output that I need to accept the SDK licence agreements but not sure how or why that needs to be done. The tutorials I followed didn't need to do any of this...not sure why it's so weird.
EDIT: Marked in error as a duplicate. It's not a duplicate because the solution from 3 years back does not work for me and I have two other errors which are not mentioned at all in the duplicate question.
In addition the solution to my problem was to remove the second installation of the Android SDK that was installed by Homebrew. None of this is mentioned in the supposed question this is a 'duplicate' of.
Let me clarify your comments first: I didn't downvote, but your wording leaves a lot to be desired. Android Studio is not my beloved anything, it's just a tool that I use for the lack of a more convenient one. What you're experiencing is not an Android Studio installation issue, this is an Android toolchain problem.
What's going on?
Your Android toolchain is broken.
What to do?
I'd take a few steps here to verify where is your problem originating, for it's hard to tell without being able to reproduce it. Instead, I'm going to tell you what steps I would follow if I encountered a fresh install of macOS (or any other OS, since I don't run macOS anymore).
Download Android Studio from Google.
Android Studio comes with some bundled basic stuff, but for the most part, it's recommended that you complete the missing keys, using the integrated SDK Manager. It's available in the very first Android Studio welcome popup that says "Welcome to Android Studio". Pick the "Configure" at the bottom and then "SDK Manager":
Notice at the top, my location where I saved all this; this must be set as ANDROID_HOME environment variable, and some of these folders must be in your Path (for easier access to any tool, notably the adb command). So if you use BASH (default for macOS High Sierra), ensure you add this to your .bashrc or .bash_profile or anywhere where you have configured your path.
export ANDROID_HOME="$HOME/Android/Sdk"
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
You get the idea.
Unfortunately, you also need Java, something macOS doesn't deliver these days anymore. So you have a bunch of choices here. You can head over to Oracle's downloads for Java 8 and chose the right one for your environment, or you can install the OpenJDK. In any case, if you need to see where you Java install(s) are, macOS has a handy tool called java_home. You can read more about it in this StackOverflow post.
java_home doesn't exist on my Linux, but I know where my java is, and I can see it because I added this environment variable, which is needed:
$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64
Now that I have that in my path, I can run the Java binaries:
$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.19.04.2-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)
What about the licenses
The SDK manager is capable of approving the licenses from the command line in a semi-automated form because that's what Continuous Integration environments use. If your CI environment is freshly created for every pipeline (To ensure things work from fresh every time), then they, too, need to download the SDK and accept the licenses. That's where the SDK manager license enters the picture.
It's hard to tell what's going on with yours in particular, but rest assured, it's not a normal occurrence in my experience. It's mostly easy to realize that all it needs is a file in the right place to stop asking for approval, and what not. But all that is not needed if you use the SDK Manager UI because it will prompt you to accept the licenses right there in the UI.
After you have JAVA_HOME, ANDROID_HOME, etc. all set up. If you type adb --version, it should work, no matter where you are:
$ adb --version
Android Debug Bridge version 1.0.41
Version 29.0.1-5644136
Installed as /home/martin/Android/Sdk/platform-tools/adb
After all this, and assuming your Android Studio SDK pointer is pointing to the right place, then you should be good to go.
Keep in mind, projects can elect to use the embedded JDK (and in fact it says recommended) so if Java works for you, ignore the way I install Java :) (I prefer to use my own copy of the JDK, I got used to it). Remember this is a per-project setting.
How about HAXM?
HAXM is an Intel proprietary tool, and all Android Studio / SDKManager does is download but not install (as far as I remember). In any case, the official Google steps to install it on macOS, clearly say, on step 4 (and I quote the above link):
After the download finishes, run the installer. Typically, you can find the installer in the following location: sdk/extras/intel/Hardware_Accelerated_ExecutionManager/IntelHAXMversion.dmg
UPDATE
HAXM: this is an Intel Tool and it has security implications and requires elevated permissions (in the case of macOS, to install a kernel extension) among other things, so you must complete the installation on your own. The only thing the SDK Manager used to do was just download the file, I don't think it launches the install on its own. Installing HAMX is relatively straightforward now; you can even download it from Intel and install it on your own.
Regarding your Homebrew thing, I'm not sure what's going on but I haven't used Flutter to do Android Development, so my help here will be limited in that regard. I'd try to brew uninstall whatever is conflicting here or at least try to figure out why Flutter is pointing to the wrong SDK. Take my flutter advice as coming from someone who hasn't installed Flutter ever and is just guessing with no proof :)

SDK directory is not writable when building Android project on Ubuntu agent of Azure Pipelines

I'm configuring my build pipeline for an Android project. So far, all of my steps are working perfectly on Hosted VS2017 agent, including fetching the code, building with gradlew, publishing the artifact and deploying it to AppCenter.
However, on Hosted Ubuntu 1604, there are a few problems with gradlew step.
On VS2017 agent, this works with just: .\gradlew assembleDebug
On Ubuntu 1604, this is what I'm having right now:
chmod 775 gradlew
chmod 775 /usr/local/lib/android/sdk --> The fix I'm working on
./gradlew assembleDebug
Running the build without the 2nd line, agent will throw this exception:
What went wrong: A problem occurred configuring project ':app'.
Failed to install the following SDK components: build-tools;28.0.3 Android SDK Build-Tools 28.0.3
The SDK directory is not writable (/usr/local/lib/android/sdk)
I'm a beginner with Ubuntu... why is it not writable? I tried to chmod but I got the exception while doing so: chmod: changing permissions of '/usr/local/lib/android/sdk': Operation not permitted.
Which direction should I look at to solve this problem now... ? Thank you all in advance!
Change the ownership of Android SDK:
sudo chown -R $(whoami) $ANDROID_HOME
I had the same problem on a standard Ubuntu install.
The solution: install the Android SDK in your home directory.
The problem is, building a project with Gradle fails to work with a read-only SDK. Installing the Android SDK with apt leaves it read-only.
More precisely, everything in /usr/ is supposed to be read-only data, so it's owned by root with permissions set to 755. Your user doesn't have write access to it, only the owner does. Installing the SDK in your home directory (and making sure your user owns it) should solve the issue.
Installing the SDK
I haven't seen a good way to install just the SDK. There's another SO question addressing this; one of the ways listed there ought to work.
However, you may find it easier to just install Android Studio, and pick a custom location for the SDK.
Hope it helps!
there is no need to reinstall something at all...
giving the write privilege to the currently logged in user solves the problem.

Is there a Rust build for aarch64-linux-android?

Recently I got a new smartphone with fairly beefy specs, so wanting to play around with Rust on the go I installed Termux and tried to rustup-init. However, this fails:
info: syncing channel updates for 'stable-aarch64-linux-android'
info: latest update on 2017-08-31, rust version 1.20.0 (f3d6973f4 2017-08-27)
error: target not found: 'aarch64-linux-android'
Is there another way to get a Rust environment on android?
Sadly rustup won't work on android.
You can manage to install cargo and rustc using Termux "its-pointless (live_the_dream)" community repository.
Also if you have rustup already installed, rm .cargo will remove the stub (which otherwise interferes with calling cargo or rustc).
There is a rust package available via pkg install rust. It contains Cargo and appears to install packages successfully.
The package source is here: https://github.com/termux/termux-packages/tree/master/packages/rust
Just a note: I had a binary failing to build during installation via Cargo due to libsqlite3-sys intermediate. This was solved by installing binutils package, which adds the archiver (ar) aarch64-linux-android-ar.

Can't find 'apksigner' executable to manually sign APK

Following the Sign Your App Manually guide,
You can sign your app from the command line using standard tools from the Android SDK and the JDK
I should have apksigner somewhere to run
$ apksigner sign --ks my-release-key.jks my-app.apk
Where is this executable supposed to be? The documentation never specifies where I'm supposed to get the tool on the Signing guide or the apksigner doc.
I don't recall having this problem last time I manually signed an app. I've searched all the directories I can think of with no luck (including subdirectories):
AppData\Local\Android\sdk
Program Files\Android\Android Studio
Program Files\Java\jdk1.8.0_91
Googling for 'apksigner' just seems to turn up a number of unofficial apk signing tools but no official download. What am I missing?
Running Android Studio 2.2, Build Tools 24.0.2, JDK 1.8
Thanks
ANSWERED: Updating to to 24.0.3 solves it. Thanks to Alex Klyubin, please upvote his answer. For some reason Build Tools 24.0.2 simply does not have apksigner.
Build Tools, Revision 24.0.3 (September 2016)
Added apksigner, an APK signing tool to replace jarsigner ...
apksigner shipped with Android SDK Build Tools 24.0.3 (see https://developer.android.com/studio/releases/build-tools.html). The tool can be found in the Android SDK's build-tools/<tools version> directory. For example, build-tools/24.0.3/apksigner on Linux/OSX and build-tools/24.0.3/apksigner.bat on Windows.
On mac The Apksigner is inside build tools all you need is this line
/Users/adewale***/Library/Android/sdk/build-tools/28.0.3/apksigner verify MyApp.apk
just change /Users/adewale***/Library/Android/sdk/build-tools to your build tools path.
Done
I was facing the same problem on windows 10, I found apksigner.jar jar file in the following path:
C:\Users\miaou\AppData\Local\Android\Sdk\build-tools\29.0.2\lib
I did copy the .jar file and paste it inside platform-tools folder inside Android sdk directory
On Windows 10 it should be under directory
C:\Users\{user}\AppData\Local\Android\Sdk\build-tools\
Note the AppData directory is by default hidden.
First make sure you installed Android SDK 24.0.3 or later.
Use this command will work for sure (For Windows)
--Go to this directory
C:/Users/{UserName}/AppData/Local/Android/Sdk/build-tools/29.0.0/
--Type this command :
apksigner.bat verify {PathToApp/AppName}.apk
Full Example :
C:/Users/Surya/AppData/Local/Android/Sdk/build-tools/29.0.0/apksigner.bat verify C:/AndroidApp/test.apk
On windows I couldn't use apksigner even with build tools version 31.0.0.
finally used apksigner command with .bat postfix and it worked fine.
for example
apksigner.bat verify AppName.apk
If you have downloaded command-line tools and haven't extracted "build-tools" folder yet then open cmd and go to folder's location where your SDKManager is present and then run the following command:
//sdkmanager build-tools verison number like following command
sdkmanager build-tools;31.0.0
"apksigner.jar" comes inside the build-tools\version number\lib folder.
After running the above command, set the path (where your apksigner.jar is present) in environemnt variable.
You can check list of build tools versions from following link:
https://developer.android.com/studio/releases/build-tools
Or simply you can run following command in the cmd:
sdkmanager --list
just store this in path environment values: %LOCALAPPDATA%\Android\Sdk\build-tools\32.0.0

How do I put my cordova application on the android play store?

If there is official cordova documentation for this, I couldn't find it and would appreciate a link. I have run cordova run android to deploy to my phone. Things look good. Now I'm ready to turn this into an official app that users can download on the android play store? When I build my app it generates a file named "CordovaApp-debug.apk". That "debug" part makes me think this is the wrong file to work with, but I'm not sure how to generate the right file.
Deploying a hybrid app to the Google Play Store
These steps would work for Cordova, PhoneGap or Ionic. The only difference would be, wherever a call to cordova is placed, replace it with phonegap or ionic, for your particular scenario.
Once you are done with the development and are ready to deploy, follow these steps:
Open a command line window (Terminal on macOS and Linux OR Command Prompt on Windows).
Head over to the /path/to/your/project/, which we would refer to as the Project Root.
While at the project root, remove the "Console" plugin from your set of plugins.The command is: cordova plugin rm cordova-plugin-console
While still at the project root, use the cordova build command to create an APK for release distribution.The command is: cordova build --release android
The above process creates a file called android-release-unsigned.apk in the folder ProjectRoot/platforms/android/build/outputs/apk/
Sign and align the APK using the instructions at https://developer.android.com/studio/publish/app-signing.html#signing-manuallyAt the end of this step the APK which you get can be uploaded to the Play Store.
Note: As a newbie or a beginner, the last step may be a bit confusing as it was to me. One may run into a few issues and may have some questions as to what these commands are and where to find them.
Q1. What are jarsigner and keytool?
Ans: The Android App Signing instructions do tell you specifically what jarsigner and keytool are all about BUT it doesn't tell you where to find them if you run into a 'command not found error' on the command line window.
Thus, if you've got the Java Development Kit(JDK) added to your PATH variable, simply running the commands as in the Guide would work. BUT, if you don't have it in your PATH, you can always access them from the bin folder of your JDK installation.
Q2. Where is zipalign?
Ans: There is a high probability to not find the zipalign command and receive the 'command not found error'. You'd probably be googling zipalign and where to find it?
The zipalign utility is present within the Android SDK installation folder. On macOS, the default location is at, user-name/Library/Android/sdk/. If you head over to the folder you would find a bunch of other folders like docs, platform-tools, build-tools, tools, add-ons...
Open the build-tools folder. cd build-tools. In here, there would be a number of folders which are versioned according to the build tool-chain you are using in the Android SDK Manager. ZipAlign is available in each of these folders. I personally go for the folder with the latest version on it. Open Any.
On macOS or Linux you may have to use ./zipalign rather than simply typing in zipalign as the documentation mentions. On Windows, zipalign is good enough.

Categories

Resources