I am creating an application with Java in Android Studio. I commented and documented my code and and I created a documentation with the integrated JavaDoc tool. But how can I comment the R.java class that is generated automatically after building the project? I want to add the sources of images as a comment to the drawables so that the user can see where my pictures are from when reading the JavaDoc documentation.
The R.java class is generated by the build system, and therefore your edits will almost certainly be erased upon the next build of the app.
I'd suggest instead adding documentation to the corresponding Activity or Fragment's javadocs if you're following a "code behind" pattern.
Related
I'm handling an Android Project my company started last year.
I got a GreenDaoGenerator project with the infamous custom ExampleDaoGenerator.java. I'm pretty sure this is all well configured in order to work well and generate my entities.
I started developing the Android Project (which is in another folder/package, of course) but now I need to change the way Entities are instantiated in it.
I have a good amount of classes with the
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit.
on the top of them and I'd like to re-generate them since I commented out some rows in my custom ExampleDaoGenerator.
How can I do that? GreenDaoGenerator is not an Android Studio project, doesn't have any build.gradle file. It doesn't have any .class file either, just the java file and libraries to load for DaoGeneration. I didn't find anywhere in GreenDao documentation how to run the proper generation and harvest the created classes.
I tried of course javac the.full.path/src/whatever/ExampleDaoGenerator.java but it didn't work :-(
Do you happen to see what I'm doing wrong? I expected Android Studio Project to re-generate the database whenever the signatures are changed but it seems like it does not.
Thank you
You need to add a Java library module (File > New > New module..) to your Android project (assuming you're using Android Studio), and insert the generation code inside public static void main(String[] args) {} in this module's .java class. Then Run it and the code will be generated in you main app's module.
See how I did it in my blog post.
mmm.... manually? backup previous created classes (model), run the generator again and compare-update data?
I don't know if there are any new doc here, but allways is a good reading place. get project also available.
Good luck!
Details: I have reinstalled eclipse 3 times, updated it & the ADT and DDMS, too.
I have found out that when I create a new android project the scr file is nearly empty. In each Activity there is only one java file and the rest is missing. I have attached a screenshot from the Maste/Detail flow activity so that you see where the problem is.
If you can help me please leave a response.
This is not a bug - it might generate additional files
depending on what starting activity you choose e.g. login activity it requires additional logic for working with Google+, however most will contain all the logic for a specific activity in a single source file, the source code included in the source files will often be minimal to make sure the activity works without the developer having to manually implement things they might otherwise not know about e.g. the fragment activity.
You might want to try out android studio instead if you are not dependent on eclipse as android seems to be moving towards using it and gradle.
(I do use android studios and am currently working on android apps and even though it's in beta it has not given me any problems)
This is a reported bug. Refer to https://code.google.com/p/android/issues/detail?id=72571
To solve the problem, look for ftl files in the tools\templates\activities subfolder of the SDK. In the files found, change <#if appCompat> to <#if appCompat?has_content>, and ${appCompat?string('Fragment','')} to ${(appCompat?has_content)?string('Fragment','')}.
So I am trying to publish an Android app to the store, and I get the error message to remove all debugging from the app. Well I started to do research and the only thing I can find are post from nearly 4 years ago and people saying to use ProGuard. Well I am not exactly a Android Developer, and I don't really know any Java. I am using Android Studio to create a simple WebView application for my website. So what files and exact code do I add/remove to so I can get this published. I have added the below code the AndroidManifest.xml to the activity:
android:debuggable="false"
What else? I don't know exactly where to put the code I have seen in past StackOverflow questions. Is ProGuard now integrated into Android? I'm so confused.
EDIT** I have made sure that there are zero calls to Log, and there are no startMethodTracing() and stopMethodTracing() in my code. I am simply following the guide on how to create a simple webview app. I have created only one class myself. Also I cannot find the project.properties file in Android studio.
A few things to try:
If there are any calls to stopMethodTracing() or startMethodTracing(), make sure you remove them.
Make sure android:debuggable="false" (as you have done)
Remove or comment any references to android.util.Log such as Log.d() or Log.i()
Export your app as a signed application package, using your developer key. This automatically runs zipalign and cleans up any unnecessary resources.
(Optional) Modify your project.properties file to and uncomment the proguard.config line. This should point to a proguard.cfg file that was probably generated automatically when you created the project. Proguard will obfuscate and minimize your code.
I have done this with iOS perfectly and now I need it for Android. I have one codebase that can create unlimited different apps with a simple config file change.
Each app is created based on a complex XML config file that I included in the resources. All I make is one simple change in my strings.xml file and it points to the config file needed, which in turn makes this my project a new standalone app. Easy.
<string name="xmlconfig">nike-shoes</string>
But now that I have done that, how do I make the change so each app is it's own APK?
How can I switch between apps (and uploadable apk's) easily with one codebase and one project. I have heard people say "use a library and then just create a project for each that includes it" but that gets overly complicated when you have 15+ apps and growing.
And I've also seen people say "why not just make one app where you can switch between them all within the app" but that also is irrelevant to my project and doesn't make sense to my users. I can't explain more than that unfortunately, but the short answer is that this won't work as well.
What I did on the iOS project I have is that I just change the Bundle ID, change the code signing identify to match, change the app name, and point to the new plist from within my main Info.plist file. BAM! Whole new app. A few simple steps that takes me less than a minute.
How can I do this with Eclipse/Java/Android? What is the easiest way?
A few steps is fine, as long as I am not mucking with every file to get it done.
I figured I would answer my own question here using Android Studio (2.2.3 at the time I'm typing this), do the following:
In your AndroidManifest file, click on your package name (click the whatever part of com.myapp.whatever) and then hit Shift+F6. Choose "Rename package" and then rename it (without the com.myapp part). Don't do it for comments, strings, and text unless needed. You'll need to approve the refactor with the button at the bottom of the Android Studio window.
Check your build.gradle file and make sure your applicationId under defaultConfig matches what you changed it to.
In your strings.xml file, change your app_name and other strings as needed to make your app its own.
Takes me about 1-2 minutes to have a whole new app. Hopefully someone else finds this useful.
All you need to do is change the package name in the manifest(and a little re-factoring in your code file due to base package name changed), and the next build will create a new App.
If you want to maintain all your apps I would also recommend to create a branch for each app that will contain this change set. this way you can fix something and push it to all versions.
Lets say you change com.foo to com.foo.bar, then rebuild, all your R imports should be now added .bar, just find replace import com.foo.R to com.foo.bar.R, thats about it.
Convert your initial project in a library project, then reference to it from all other projects. This way you have a big advantage: all modification made to the library project are yet available in the other projects. Refernce: http://developer.android.com/tools/projects/projects-eclipse.html#SettingUpLibraryProject
Does anyone know of any Eclipse plug-in or anything that can be used to automatically generate Java code from layout file? As in, if I have an EditText in my layout file with the ID "#+id/txtHello", I expect something like the following to be generated:
EditText txtHello = (EditText) findViewById(R.id.txtHello);
Thanks for your time!
Harris :)
Normally there are three different ways to do this:
at run time (via annotations per reflection)
at compile time (via annotations or aspects)
at development time (via code generators)
A good article to start is Clean Code in Android Applications.
Ad 1) Two solutions, see
RoboGuice, see http://code.google.com/p/roboguice/
AndJect, see https://github.com/ko5tik/andject
Ad 2) Android Annotations, see http://androidannotations.org/
Ad 3) Two solutions, see
the lazy-android plugin as mentioned in this thread, see http://marketplace.eclipse.org/content/lazy-android
MotoDev Studio (available as standalone and as eclipse plugin), see http://developer.motorola.com/docstools/motodevstudio/
If there is more, please tell!
I personally prefer 2) and therefore Android Annotations.
Hope that helps!
Use this online tool:
http://www.buzzingandroid.com/tools/android-layout-finder/
It simply gets the job done quickly. I use it every day.
There is an Eclipse plugin that does exactly what you want , I guess: http://marketplace.eclipse.org/content/lazy-android
There is new plugin that can generate Activity, Fragment, Adapter based on xml layout.
Can also generate Menu related code (handling actions) for xml menu files. And has editable templates, so the user has more control on the generated data.
For Eclipse:
http://tmorcinek.github.io/android-codegenerator-plugin-eclipse/
For Android Studio/IntelliJ IDEA:
http://tmorcinek.github.io/android-codegenerator-plugin-intellij/
I use MotoDev Studio. It really saves time.