in Android Studio (2.2 Preview 2), I have the sdk sources attached and I can also jump to the interfaces of android sources: e.g. when I CTRL-click on SharedPreferences, the file ~/Android/Sdk/sources/android-23/android/content/SharedPreferences.java is opened.
But now I also want to jump to the implementation of this interface - or a member function e.g. getFloat()
How can this be done?
notes:
clicking CTRL-ALT-B only show the error no implementations found
the relevant file SharedPreferencesImpl.java exists in the location where I expect it: ~/Android/Sdk/sources/android-23/android/app
the compileSdkVersion is set to 23 in my build.gradle file
Maybe I found the solution. The implementation class signature looks the following:
final class SharedPreferencesImpl implements SharedPreferences {
This is the default access modifier and means that it is only visible in the current package android.app. But your interface is defined in another package android.content thats why Android Studio cannot find the implementation.
But even If you click through your "External Libraries" in Android Studio of your project you cannot see the android.app.SharedPreferencesImpl class ...
I found a workaround to easily get me to the implementation file:
Set the cursor to the interface-name SharedPreferences
Open the Find Usages dialogue (e.g. press CTRLALTSHIFT7). In the Scope box select Project and Libraries.
Click the Find button and the SharedPreferencesImpl class will show up in Found usages (under the Android API 23 Platform node)
Related
I created an Android library that was originally coded with Java and it outputs an .aar file that I use in some of my projects.
When I include this lib in a project (an Android project created with Kotlin) and I decide to debug the code in this project, when the debugger reaches a line containing a library's class, it successfully steps into the class and I can see the source code of the class while I'm debugging it. I can continue the debug line by line inside the lib's class and everything works as expected.
However, I recently decided to convert this library to Kotlin but now, when the debugger reaches one of the lib's class and I step into the class to continue debugging there, I can no longer see the entire source code. I can only see the method signatures, but without the method definitions. I see only things like:
public class ClassA {
public fun function1(): kotlin.Unit
public fun function2(): kotlin.Unit
public fun function3(): kotlin.Unit
}
I didn't do any else in the library's project settings. I simply converted the files from .java to .kt.
Here are some things that I tried so far to solve this problem:
I confirmed that I included Kotlin's standard lib in the dependencies list of the build.gradle file in the library.
I disabled ProGuard (it has never been a problem, but I removed it just in case).
I disabled code minification (it has never been a problem too, but at this point I'm willing to try anything).
Anyone has any idea why this is happening?
While debugging when it prompt "Choose Sources", Click on that option
and select the "main" folder of the library module from your local codebase of the library
Now try to debug (by choosing 'step into' option etc), the debugger should able to get the source code.
I am on Android Studio 1.5.1
falnatsheh/MarkdownView
In the project's readme at github its gives instructions for use. These don't cover actually adding the project .. and I am learning Android programming (in fact I am making an app to keep my notes, as a sort of second step after "hello world").
how do I add it to the project so that I can follow the instructions on the project's readme? My default attempt was to follow these instructions:
File -> New -> Import Module .. add as ":markdownview" in my case, add it to the app's build.gradle, and then that should be it according to the site.
But that doesn't work:
The project's readme starts by saying you should add "compile 'us.feras.mdv:markdownview:1.1.0'" to the dependencies file (I am assuming they mean the Module:app one)... which looks like another way to add ":markdownview" to me.. but I did that too (and that instead of the ":markdownview"). Still the symbol does not resolve.
how do I add it to the project so that I can follow the instructions on the project's readme?
Add the following to your app/build.gradle file:
dependencies {
compile 'us.feras.mdv:markdownview:1.1.0'
}
which looks like another way to add ":markdownview" to me
Not exactly, but close.
but I did that too (and that instead of the ":markdownview"). Still the symbol does not resolve.
As with everything else in Java, you need to add an import statement.
I just created a scrap project in Android Studio, accepting all defaults in the new-project wizard. I pasted the above snippet in app/build.gradle and let Android Studio sync with the project files. I then added a reference to MarkdownView in the Java file, and Android Studio picked up the import without issue.
I know that similar questions have been on SO and I have read through and tried to implement the solutions mentioned but nothing is working. The specific problem is like this (using ECLIPSE):
I am trying to implement location awareness in one of the activities (triggered through menu selection) in my app. As long as my code looks like,
"public class MealHistoryActivity extends Activity {...}",
I don't get any error. As soon as I modify it to
public class MealHistoryActivity extends Activity implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener {..",
it throws in the following error:
E/AndroidRuntime(5027): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.package.activities.MealHistoryActivity" on path: DexPathList[[zip file "/data/app/com.package.activities-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
What I have tried:
Adding up the library projects (support library as well as google play services) and cleaning all the projects.
Including Android Private Libraries for the application as well as the library projects.
Double-checking the API key in android manifest as well as the SHA-1 fingerprint key associated to it.
Using all the internet and network permissions in the manifest that are needed for location services.
Would greatly appreciate any ideas on how to solve this since I am stuck on it for the last few days!
The error suggests that the classes from the google-play-service project are not loading.
Make sure you are referencing a copy of the project in your workspace, and not the copy that is in the sdk directory. Try doing that or deleting the google service project from your workspace and redoing the steps in this guide.
Another possible cause for this is version mismatch. If your device's version is less than the version specified in the above mentioned guide than the google services project will not install on your device at all.
I am trying to run this example. I reached upto "Modify the Client Application" and I am then having the following errors (and below is my file organization screenshot:
At this stage, as you can see below, I have the following issues in MainActivity.java.
activity_main.xml is called out but the project in its layout folder only has activity_register.xml (see here)
"Checkinendpoint" class is undefined but there is a CheckInEndPoint.java in the "MobileAssistant-AppEngine" project, as you can see in the image below. Is that not supposed to get picked up in MainActivity.java - how to import that? (doesnt work like a normal library import, i.e. "MobileAssistant-AppEngine" is not a library that "MobileAssistant" can reference.
Same question as above for CheckIn class that is also undefinted in the picture below.
Delete deviceinfoendpoint-v1-generated-source & messageendpoint-v1-generated-source from the Project-MobileAssistant and then right click on the MobileAssistant-appengine project then click on Generate Cloud EndPoint Library from Google Sub menu.
I am not familiar with using Android Studio. Earlier I used Eclipse. Could you explain me what is gradle in Android studio. I have problem with Android Studio. What confused me is that it uses the same android sdk as eclipse but when I create a new project weird things happens:
There is required :com.android.support:appcompat-v7:+ (what it is ? eclipse does not require it)
My MainActivity extends ActionBarActivity instead of Activity why is that ?
Its a support library called appcompat. You need to reference that if you need actionbar below api level 11 (Whether its android studio or eclipse).
If you need actionbar below api level 11 your Activity needs to extend ActionBarActivity.
If you are targetting api level 11 and above then you don't need to extend ActionBarActivity and reference AppCompat. You can simply extend Activity and you will have actionabr by default.
Check Adding the Action Bar in the below link.
http://developer.android.com/guide/topics/ui/actionbar.html
Check for Adding libraries with resources using Android Studio #
https://developer.android.com/tools/support-library/setup.html
Actiobbar is introduced in api level 11. com.android.support:appcompat-v7:+ is a support library which allows you to have an ActionBar in your app for devices running on Android 3.0 or below.
Android Studio default project includes it automatically in dependencies and extends ActionbarActivity instead of Activity in order to use it.
You can check the same in your module's build.gradle file, you will find something like this under your dependencies block.
compile 'com.android.support:appcompat-v7:+'
There are two possible solutions to get rid of this
Remove above line from dependencies block and extend Activity instead of ActionBarActivity in your Activity classes.
Download support repository from Android SDK Manager.
Support Repository and Google Repository shown in SDK manager are not required for Eclipse but in order use Google Play Services and Support libraries in Android Stodio you have to download them.
EDIT(android plugin not found error, asked in comments below ) :
Make sure you have this either in your root level build.gradle file or at the top of module's build.gradle file to let build system know where your gradle pguin is and what is the version :
(before apply plugin: 'android')
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}