Posts

Showing posts with the label Android Studio

Android Studio Rendering Problems

Image
Answer : Change your android version on your designer preview into your current version depend on your Manifest. rendering problem caused your designer preview used higher API level than your current android API level. Adjust with your current API Level. If the API level isn't in the list, you'll need to install it via the SDK Manager. In new update android studio 2.2 facing rendering issue then follow this steps. I fixed it - in styles.xml file I changed "Theme.AppCompat.Light.DarkActionBar" to "Base.Theme.AppCompat.Light.DarkActionBar" It's some kind of hack I came across a long time ago to solve similar rendering problems in previous Android Studio versions. Open AndroidManifest.xml Change: android:theme="@style/AppTheme" to something like: android:theme="@style/Theme.AppCompat.Light" Hit "refresh" button in the "Previev" tab.

Android NDK With Google Test

Answer : If you choose cmake to drive your externalNativeBuild (and this is the preferred option, according to Android Developers NDK guide), then you can simply add the following lines to your CMakeLists.txt : set(GOOGLETEST_ROOT ${ANDROID_NDK}/sources/third_party/googletest/googletest) add_library(gtest STATIC ${GOOGLETEST_ROOT}/src/gtest_main.cc ${GOOGLETEST_ROOT}/src/gtest-all.cc) target_include_directories(gtest PRIVATE ${GOOGLETEST_ROOT}) target_include_directories(gtest PUBLIC ${GOOGLETEST_ROOT}/include) add_executable(footest src/main/jni/foo_unittest.cc) target_link_libraries(footest gtest) If your build succeeds, you will find app/.externalNativeBuild/cmake/debug/x86/footest . From here, you can follow the instructions in README.NDK to run it on emulator or device. Notes : make sure that the ABI matches the target you use (the guide is not very clear about this). the list of ABI's that are built is controlled by abiFilters in build.gradle . In Android ...

Can't Install Android Emulator For AMD Processors

Answer : I found the answer after long time. I had to enable Virtualization on my machine. If you are using Avast antivirus (Or AVG), The problem may be in it. So things to do to fix this: -Activate Virtualization in bios -Deactivate Hyper-v and hypervisor platform in "activate/desactivate windows function" & run powershell as admin and make :"Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V" -In Avast Antivirus. In settings click Troubleshoot on the left side of the screen, uncheck the box next to Enable hardware assisted virtualization, then click OK to confirm and restart your computer I've got the solution from https://github.com/google/android-emulator-hypervisor-driver-for-amd-processors/issues/10#issuecomment-715423881 If You are using AMD Ryzen Just go to bios setting check for SVM Mode if it is Disabled then Enable it .. Emulator work perfectly..Below Link show where to enable SVM Mode in Aorus Gigabyte Motherboard BIO...

Could Not Find Com.android.tools.build:gradle:5.6

Answer : Don't confuse gradle with the Android Gradle plugin. classpath 'com.android.tools.build:gradle:5.6' It is the Android Gradle plugin and 5.6 doesn't exist . Use the latest stable release: classpath 'com.android.tools.build:gradle:3.5.0' Check the release notes for other versions. To change the gradle version, edit the file gradle/wrapper/gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip More info in official doc. There is currently no version 5.6 for the Gradle plugin version. The link below lists all the latest releases for the Gradle plugin versions on Google's Marvel repository. https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google I think what you mean is the distributionUrl version in your Gradle wrapper properties: Go to your gradle-wrapper.properties file and complete as required: distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GR...

Android Mirror Vector Drawable

Image
Answer : For those who Use ImageView or TextView or EditText Scale works perfectly. Use android:scaleX="-1" //To flip horizontally or android:scaleY="-1" //To flip vertically OR Try android:rotationX="180" // for horizontal android:rotationY="180" // for vertical OR Simply rotation="180" for vertical android:rotation="180" // for vertical Edit: Additional If you want to flip/mirror icons/drawable when changing language RTL/LTR ("Right To Left"/"Left To Right"), there is a nice way of doing so in android vector drawable just check the ckeckbox Enable auto mirroring for RTL layout . => Right Click on drawable folder => New => Vector Asset => Select drawable => check the Checkbox . I am using AndroidStudio 3.0.1 in Windows 10 . well, there is no need to create another vector image, you can do it with one single vector image just make sure you do the following st...

Android Studio : How To Uninstall APK (or Execute Adb Command) Automatically Before Run Or Debug?

Answer : adb uninstall <package_name> can be used to uninstall an app via your PC. If you want this to happen automatically every time you launch your app via Android Studio, you can do this: In Android Studio, click the drop down list to the left of Run button, and select Edit configurations... Click on app under Android Application, and in General Tab, find the heading 'Before Launch' Click the + button, select Run external tool, click the + button in the popup window. Give some name (Eg adb uninstall) and description, and type adb in Program: and uninstall <your-package-name> in Parameters:. Make sure that the new item is selected when you click Ok in the popup window. Note: If you do not have adb in your PATH environment variable, give the full path to adb in Program: field (eg /home/user/android/sdk/platform-tools/adb). example adb uninstall com.my.firstapp List the packages by: adb shell su 0 pm list packages Review which package you w...

Android Studio Design Editor Is Unavailable Until After A Successful Project Sync

Answer : Just sync your project with gradles. File --> Sync Project with Gradle Files Build -> Clean Project Build -> Rebuild Project File -> Sync project with gradle files . If not worked then try File -> Invalidate Caches / Restart . It's work for me !!!

Android Item Size In Layer-list

Answer : I found solution, but I expected better way. Here is final code: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:endColor="#000004" android:gradientRadius="1000" android:startColor="#1f3371" android:type="radial" > </gradient> </shape> </item> <item> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/texture_5" android:tileMode="repeat" /> </item> <item android:drawable="@drawable/logo" android:bottom="214dp" android:top="214dp" ...

Android Resource Compilation Failed In V3.2

Answer : I was facing this issue today after updating gradle from 3.1.4 to 3.2.0 . I don't know why, but the build started to throw that exception. i deleted the build folder, and deleted the gradle caches folder but nothing worked, so i looked at the merged values.xml and turns out that my ids.xml was defining a wrong id that was being merged to the values.xml : <?xml version="1.0" encoding="utf-8"?> <resources> <item name="downloading_package" type="id">Baixando pacote de sincronização</item> </resources> And apparently this was working before the update... for my case i deleted the ids.xml file (it was useless in the project) I wish i could know why before the update everything was working the <item> in values.xml at line 900 ...might be of resource-type id . the correct syntax would be (just as the error message tells): <?xml version="1.0" encoding="utf-8...

Android SDK Location Should Not Contain Whitespace, As This Cause Problems With NDK Tools

Answer : As the warning message states, the SDK location should not contain whitespace. Your SDK is at C:\Users\Giacomo B\AppData\Local\Android\sdk . There is a whitespace character in Giacomo B . The easiest solution is to move the SDK somewhere else, where there is no space or other whitespace character in the path, such as C:\Android\sdk . You can point both Android Studio installations to the new location. There is another way: Open up CMD ( as Administrator ) Type: mklink /J C:\Program-Files "C:\Program Files" ( Or in my case mklink /J C:\Program-Files-(x86) "C:\Program Files (x86)" ) Hit enter Magic happens! ( Check your C drive ) Now you can point to C:\Program-Files ( C:\Program-Files-(x86) ). just change the path: "c:\program files\android\sdk" to "c:\progra~1\android\sdk" or "c:\program files (x86)\android\sdk" to "c:\progra~2\android\sdk" note that the paths should not contain spaces.

Could Not Find Com.android.tools.build:gradle:4.0.1 OR 4.0.0

Answer : this solution just work in iran go to -> File | Settings | Appearance & Behavior | System Settings | HTTP Proxy, and choose -> manual proxy configuration. set host name: fodev.org and set port number: 8118 . now you must find gradle.properties file. that must be in: Windows: C:\Users\YOURUSERNAME.gradle\gradle.properties OR for Linux: ~/.gradle/gradle.properties . if does't exist, create that yourself. and copy this : systemProp.http.proxyHost=fodev.org systemProp.http.proxyPort=8118 systemProp.http.nonProxyHosts=*.jitpack.io, *.maven.org systemProp.https.proxyHost=fodev.org systemProp.https.proxyPort=8118 systemProp.https.nonProxyHosts=*.jitpack.io, *.maven.org now you can sync project. IMPORTANT : after install build.gradle 4.0.1 (or every version), back this settings to before and remove codes

Android Studio Failed To Load JVM DLL

Answer : It is very late for my answer but still to the people who reference this in the future, I had the same issue. Mine was x64 bit OS and I was trying to open studio.exe which is x32 bit. I opened studio64.exe and it worked. As well as JAVA_HOME which should be set to the jdk directory e.g. C:\Program Files\Java\jdk1.7.0_21 you also have to add a path to the jdk bin directory e.g. C:\Program Files\Java\jdk1.7.0_21\bin . As you already know how to set the JAVA_HOME variable adding the extra directory to the path variable is just the same but you have to edit an existing variable and add the path separated by a semicolon e.g. add ;C:\Program Files\Java\jdk1.7.0_21\bin to the end of the path. And then restart your PC, to start the Android Studio. More details at: Getting Started With Android Studio It works like this: JAVA_HOME : C:\Program Files\Java\jdk1.7.0_21 and PATH : C:\Program Files\Java\jdk1.7.0_21\bin

Android Library Project Using Android Studio

Answer : Simplest way to do this : Right click on your opened project in Android Studio and select New > Module In the left Pane choose Android Library and click on next. Enter all details, untick Create Activity, Theme and all if not required. Choose API level same as your project and Next, Next, Next . Now you will see an another directory inside your project, build.gradle for library will be automatically configured for you. If your module/library name is "mylibrary" , include ':mylibrary' will be automatically added in settings.gradle file inside root directory of your project. Now open your main module and insert this line in dependency block : compile project(':mylibrary') If you want to use same library in other projects, you have to copy the library module to that particular project using File Explore and have to configure settings.gradle and main module's build.gradle manually. An old question, but even now there d...

Android Studio 2.2.2: All Packages Are Not Available For Download

Answer : I was facing the same issue. For me, it got resolved by setting proxy settings. Android Studio > File > Settings >appearance and behavior> System Settings > HTTP Proxy I would suggest checking any proxy is required to enable internet for your android studio. Hope this will help somebody. Open Android SDK Manager Click on Tools. Click on Android. Click on SDK Manager. Update your SDK's Then Sync ,Re-Build and Restart Your Project "Launch Standalone SDK Manager" is not available in newer versions. Just select "SDK Tools" tab, then "Android SDK Build-Tools and place a check next to 23.0.1, 23.0.2, 23.0.3, etc. and any others you may want to install. Select Apply and when complete, press Finish. Rebuild and see if that helps.

Android Studio - Android Emulator Wifi Connected With No Internet

Image
Answer : Stated below are the solutions for Windows and Mac, but similar solutions will work on any OS: On Windows Open Network and Sharing Center and click on current Connection Click on Properties Double Click on Internet Protocol Version 4 (TCP/IPv4) Set the Preferred and Alternate DNS servers as (Screenshot below) : 8.8.8.8 8.8.4.4 On Mac Go to Settings > Network > Advanced... > DNS Delete whatever entries you have there and add these two entries (Screenshot below): 8.8.8.8 8.8.4.4 Note: For Mac users, if the entries field is disabled and you're not able to edit it, click on the 'Lock' icon in the bottom area of that window and enter the password to be able to make changes Restart the emulator, and it should solve: Screenshots: Windows Mac Edit: This is the fix for a situation when the emulator's wifi has changed the DNS to some non-working DNS. While this works most of the time, there might also be other rea...

Android Studio Doesn't See Device

Answer : I recently had trouble with this, and regardless of what I did(restart adb, edit adb_usb.ini, restart computer+device+swap usb port, reinstall studio etc. etc.) I just couldnt get it to work, and could not even detect my device using 'adb devices'. Finally after about 2 hours of googling and testing, someone suggested switching to PTP instead of MTP on my device. When I did this I got a popup on my device asking me to allow my mac access and suddenly everything worked(had to restart studio for it to show up there as well though). I might be bumping this thread now, but it is the first result on google search, and I had a lot of trouble finding an answer for this problem, so I thought this should be added as a solution. On your device: Go to settings/ developer settings/ allow USB debug mode If 'allow USB debug mode' option is disabled. Then you might have the device currently connected to your PC. Disconnect the device and the option should now...

Android Icon Generator For Actionbar And Notification Not Working (grey Shape)

Image
Answer : You can use a tool for creating generic icons in Asset Studio: https://romannurik.github.io/AndroidAssetStudio/icons-generic.html. To get it look like ActionBar Icon, you should make next actions: Choose image The size of image should stay at 24dip Change padding to 4dip Move foreground color thumb to 0% That's it! Download .zip now. The sizes of icons will be pretty the same as you can get them with ActionBar Icon Generator. How it looks for me: I think it's because your image is too complexe and the main problem is the "color" filter applied in AAS. I had the same problem and I had to convert xxxhdpi xxhdpi etc. manually. If you work with Sketch (for example) it can be converted easily with a plugin (https://github.com/zmalltalker/sketch-android-assets) hope it's help ! If you want to use AAR, like @rom4ek explained "4. Move foreground color thumb to 0%" this is the important part

Android Studio Suddenly Cannot Resolve Symbol R

Answer : Most of the time it is due to a bad XML file. XML files can be layout files, value files, or the Manifest file. Please check your xml files and try to rebuild the project. Sometimes cleaning the project and rebuilding it also works. In addition, make sure you do not have a drawable with an invalid name. I had a drawable with a numeric filename and that didn't sit well with Android so it failed to compile R.java. Downgrade Your Gradle Plugin Version No amount of cleaning, rebuilding and restarting would do the trick for me. The only thing that did the trick was downgrade our Gradle version from 3.4.0-alpha02 to 3.2.1 . So, instead of: dependencies { classpath 'com.android.tools.build:gradle:3.4.0-alpha02' } We used: dependencies { classpath 'com.android.tools.build:gradle:3.2.1' } After making that change and then doing a Gradle sync, everything worked. Not sure if it's related to the alpha release or to that version or if ...

Create Aar File In Android Studio

Answer : If your library is set up as an Android library (i.e. it uses the apply plugin: 'com.android.library' statement in its build.gradle file), it will output an .aar when it's built. It will show up in the build/outputs/aar/ directory in your module's directory. You can choose the "Android Library" type in File > New Module to create a new Android Library. Retrieve exported .aar file from local builds If you have a module defined as an android library project you'll get .aar files for all build flavors (debug and release by default) in the build/outputs/aar/ directory of that project. your-library-project |- build |- outputs |- aar |- appframework-debug.aar - appframework-release.aar If these files don't exist start a build with gradlew assemble for macOS users ./gradlew assemble Library project details A library project has a build.gradle file containing apply plugin: com.android....

Android Studio Where Is Color Picker For Flutter Plugin

Image
Answer : The color picker is not clickable in Android Studio running Flutter( Dart code), see picture below. But i found a work around using the Color class and manually opening color picker. Then pick a color and copy/paste it like this: Here is how i do it: 1. Double tap shift to run search 2. Type Color or Picker 3. Open Color Picker from the search list 4. Copy/paste the HEX color code into your color class. Expert tip: Add color picker to a keyboard shortcut . You can find the settings for Keymap , under File > Settings > Keymap