android - Build and Install unsigned apk on device without the development server?

android - Build and Install unsigned apk on device without the development server?

Beatrycze Luc Author: Beatrycze Luc Date: 2022-08-15
android - Build and Install unsigned apk on device without the development server?

All you need to know about android - Build and Install unsigned apk on device without the development server? , in addintion to android - Instant Run performed a full build and install since the installation on the device does not match the local build on disk , android - Stuck at installing buildappoutputsapkapp.apk in Flutter... after uninstalling the app , How can I detect whether an Android APK has debuggable set to true or false in its manifest without installing it? , apk - Android Unsigned App not able to install on device

  1. android - Build and Install unsigned apk on device without the development server?
  2. Question:

    As I am new in react-native so if there is anything wrong in steps let me know.

    I have build a react native android app using the command as per documentation

    react-native android

    while running on device the following command was used

    react-native run-android

    which gives me the output of 2 apk files in my projectfolder/android/app/build/outputs/apk

    enter image description here

    now when I use to install this apk after the installation it ask for an development server to connect to bundle the JS. But my requirement is that the user doesn't have to struggle with the development server just he needs to install the apk and everything is done.

    Have gone through some stackoverflow Questions but not helpful to build unsigned apk which doesn't require development server.

    Can you guys help me finding the way that how to build and unsigned apk in react native?


    Solution 1:

    You need to manually create the bundle for a debug build.

    Bundle debug build:

    #React-Native 0.59
    react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest ./android/app/src/main/res
    
    #React-Native 0.49.0+
    react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug
    
    #React-Native 0-0.49.0
    react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug
    

    Then to build the APK's after bundling:

    $ cd android
    #Create debug build:
    $ ./gradlew assembleDebug
    #Create release build:
    $ ./gradlew assembleRelease #Generated `apk` will be located at `android/app/build/outputs/apk`
    

    P.S. Another approach might be to modify gradle scripts.

    Solution 2:

    Please follow those steps.

    Bundle your js:

    if you have index.android.js in project root then run

    react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug
    

    if you have index.js in project root then run

    react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
    

    Create debug apk:

    cd android/
    ./gradlew assembleDebug
    

    Then You can find your apk here:

    cd app/build/outputs/apk/
    

    Solution 3:

    React Version 0.62.1

    In your root project directory

    Make sure you have already directory android/app/src/main/assets/, if not create directory, after that create new file and save as index.android.bundle and put your file in like this android/app/src/main/assets/index.android.bundle

    After that run this

    react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
    
    cd android && ./gradlew assembleDebug
    

    Then you can get apk in app/build/outputs/apk/debug/app-debug.apk

  3. android - Instant Run performed a full build and install since the installation on the device does not match the local build on disk
  4. Question:

    Android Studio gives error when running application with instant run enabled. I have updated my android studio to 2.3 today and since then its showing me above information.


    Solution 1:

    On android studio 3.0.1 I ran a full build right after I enabled instant run. Once that was done . The error was gone and instant run worked.

    Solution 2:

    Re-run Android studio with emulator helped me to install it on next lunch.

    Solution 3:

    if you are using external devices then turn On or Off the device, or connection miss-match. please retry to connect devices and run your application then reconnect device.

  5. android - Stuck at installing buildappoutputsapkapp.apk in Flutter... after uninstalling the app
  6. Question:

    I have read this and this, but nowhere could I find a good answer. I have a problem when I try to run the app. Initially it was working completely fine, but I uninstalled my app from my Android device for some reason and now when I try to run the app on my Android phone it is stuck at installing build\app\outputs\apk\app.apk...

    llutt

    PS: it also successfully installs at my friend's device. It is only stuck when I try to run in my phone. Also other projects are successfully loaded too, but I even tried to create a new project and copy all files from the old one and tried to run, but that didn't work for me either.


    Solution 1:

    Run flutter clean and check if you have enough memory on your device.

    Solution 2:

    Re-run Android studio with emulator helped me to install it on next lunch.

    Solution 3:

    The problem occurs if your device has an incomplete installed app with the same package name.

    Solution:

    1. Uninstall any app in your device that has the same package name
    2. See the Settings/app whether it is completely uninstalled or not. If not, uninstall from there also.
    3. If possible, erase your internal storage.
    4. Push your project to GitHub
    5. Delete the project from your harddisk.
    6. Download the project and unzip it
    7. Run it

    I lost all four days regarding this problem. I tried all the solutions I found. But at last I solved this issue by doing the above things.

  7. How can I detect whether an Android APK has debuggable set to true or false in its manifest without installing it?
  8. Question:

    As the title says, I'd like to be able to find whether an APK has debuggable set to true or false on a computer without having to install it on the device, run it and see whether it shows up in DDMS or not.


    Solution 1:

    This is one of those "easy once you know how" things - Use the aapt tool to inspect the manifest.

    aapt dump xmltree YourApp.apk AndroidManifest.xml | grep debuggable
    

    That command will give you a dump of the compiled form of the AndroidManifest.xml file- the output will look something like

    A: android:debuggable(0x0101000f)=(type 0x12)0x0

    (Actual output from my command prompt) in that example, the 0x0 indicates false.

    Solution 2:

    Apparently aapt can do it:

    aapt l -a app.apk | grep debuggable
    

    will return either:

    A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff (means debuggable is true)
    

    or

    A: android:debuggable(0x0101000f)=(type 0x12)0x0 (means debuggable is false)
    

    Solution 3:

    For window user can use following command:

    aapt l -a <apk with path> | findstr debuggable
    

    will return either:

    A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
    -> this means debuggable is true.
    

    or

    A: android:debuggable(0x0101000f)=(type 0x12)0x0
    -> this means debuggable is false.
    

  9. apk - Android Unsigned App not able to install on device
  10. Question:

    My app able run on simulator and I export it as Unsigned App.

    On my phone's Setting-->>Applications--->>Unknown sources checked.

    I download the .apk into phone storage through USB.

    Then under File Manager, I found that stored .apk and hit install button and it try to install,

    But finally it says Application Not installed. but why? wht's wrong?

    Also I try ./adb install -r myapp.apk but it said error:device not found


    Solution 1:

    I have never tested an app on a device by using your method... When I am NOT debugging on my device using usb and I just want to install it on my phone, I do the following:

    1. If you have run it on the emulator then there is an .apk file in the bin directory of your project.

    2. Move that .apk to your phone via usb or another method (I use dropbox).

    3. Open the .apk and install on your phone.

    The previous answers are correct, it must be signed. But by doing my method it will be signed with your debug key.

    You will obviously want to actually sign it with a real key before publishing it to the market.

    Solution 2:

    All applications must be signed in order to install on emulator or real device, check out the official dev guide signing your application:

    • All applications must be signed. The system will not install an application on an emulator or a device if it is not signed.
    • To test and debug your application, the build tools sign your application with a special debug key that is created by the Android SDK build tools.

    Solution 3:

    Specifically how are you getting the APK to the device? Try dab install <path to APK>. Also, you can install APKs from the Android browser by uploading it to any web server and navigating to its URL.

    You must export and sign with a debug certificate before installing. Read about publishing.