I built an android project that set up with android-maven-plugin. When I execute android:deploy and run the program, SharedPreferences always initialized.
Is there a way to deploy my project to AVD without deleting SharedPreferences storage?
P.S.
I use Intellij IDEA and noticed that its native android run/debug support does not delete SharedPreferences. However, after I add scala support on my project, IDE reports "Too many methods: 112423; max is 65536" error when I run the application. Perhaps it is due to lack of proguard preprocessing. If there are a way to apply proguard before run the android app with Intellij IDEA android support, it would be an equally effective solution.
I think your app is being uninstalled before being reinstalled again - this would cause you to lose your SharedPreferences values. This can be controlled with the Android Maven plugin parameter undeployBeforeDeploy.
I just tried to create a Maven project with the android-quickstart archetype and found that it automatically added the following line to my POM:
<undeployBeforeDeploy>true</undeployBeforeDeploy>
Try to set this to false and try again.
If you have it set to true, it prints this line in the console when you run mvn android:deploy:
[INFO] Successfully uninstalled [package] from [device]
Related
I migrated from Ubuntu to Arch a couple of months ago. On Ubuntu, I built quite e few Android applications using CN1.
Now, on Arch, I am trying to build my first Android app with Maven and Eclipse, and went though the CN1 maven tuts.
After a learning curve, I got the project structured mounted and the simulator up and running, and today I wanted to install the app on my phone, but I received the following error :
Buildfile: /home/xxx/eclipse-workspace/xxx/xxxx/build.xml does not exist
I searched the entire project and the was really no such file present in any folder. (It should be automatically generated, right?)
Well, I tried to help myself and copied the build.xml file from a project that I generated from the templates to my maven project and created a couple of missing folders (like .../lib/impl/native/javase), but all to no avail.
The last error that's thrown is :
BUILD FAILED .../build.xml:434: Can't assign value '${codename1.version}' to attribute version, reason: class java.lang.NumberFormatException with message 'For input string: "${codename1.version}"'
What am I missing?
I think you're trying to use the plugin to send an Android build and it's looking for the old ant build file which is no longer there.
You need to use the appropriate launch script on Eclipse to send an Android build. The plugin is no longer needed when working with Maven as it's all handled by maven targets now.
Every time when we try to debug an app or attach to the running process android studio is triggering a gradle build. Is there any way to stop this?
It is supposed to build app in order for you to do any debugging. Your files need to be bbuilt from the plain java files to something that can be compiled and understood by the system. YOu can't debug code that has not been built by gradle.
Recently, I was working on a project in which we have a code-base and we make some changes in the application and make the application available for testing to the tester.
The changes are variables changes such as our test site name, icon and splash screen.
What we are trying to achieve is that without opening Android Studio, we can make the application package(.apk) for the code base that we have. It will save a lot of time for us
We have searched for several options which are Jenkins CI etc, but have not been able to do so.
Any sort of help regarding this topic will be appreciated.
You can run a gradle task from the console / terminal.
Go to the project root folder and run gradle + command, generally the command is gradle assembleDebug or gradle assembleRelease depending on the build type you are aiming for.
You can check the existing gradle tasks on Android Studio
We are using Robolectric for tests in Android Studio.
After a recent update from 2.2.x to 2.3 all my tests run with Robolectric (i.e. #RunWith(RobolectricTestRunner.class)) fail.
More specifically, I'm getting a ClassCastException here, as it seems that RuntimeEnvironment.application is no longer returning the custom application type created for test purposes.
MyTestApplication testApp = (MyTestApplication) RuntimeEnvironment.application;
// do something with testApp
Apparently I'm getting a plain old android.app.Application instead of the expected type...
The crux:
Neither tests, nor config were changed, the only thing I did was the AndroidStudio update (I did git reset --hard just to make sure...).
On the command line my tests run just fine, which makes me think this might be an issue with the test runner in Android Studio.
:(
I think I tried just about everything in Android Studio, like clean/rebuild, resync gradle files, invalid cache + restart... I tried to re-download and reinstall Android Studio (2.2.3 and 2.3 versions). I cleaned my local gradle cache and my local .m2 repo just to make sure, but to no avail... :(
Found the solution:
Go to Run > Edit Configuration
then in the Run/Debug Configurations for JUnit > java in app
Add $MODULE_DIR$ in the field Working directory.
I am trying to set up a CI environment with Jenkins and Robotium. I want to use the same project for both built and test, but seems so tricky to get all working. I was wondering if someone had something like that working and if it can publish at least build.gradle and the project structure. Thanks.
Have been running in production for a few months now. See this question for a sample project and video of how to use robotium with gradle.
https://stackoverflow.com/a/23295849/1965124
As for the jenkins side of things:
Install the android sdk on the machine that will be running jenkins
set up android home variable
install the android plugin
run the following tasks from inside a jenkins job: clean connectedAndroidTest
after running 1 build (it will fail the first time), change the local.properties file to point to the local installation of the android sdk.
Let me know if you need any more pointers, its not as hard as I initially thought it would be.
I configured TeamCity as CI server. Also, project builds by Gradle.
The main idea is to execute gradle connectedInstrumentTest, that task will execute all project's tests on all connected devices, then it will put the test results in standard ant-junit format, so then you can set Jenkins to parse app-folder/build/instrumentTest-results/connected/*.xml test results.
If you got more questions, you can post them to the comments.