In MainAcitivity i am using Tools.systemBarLolipop() it is function from Tools.java file
in Tools.java there is window.setStatusBarColor(global.getIntDarkColor());
comes from window.java
in window.java all android.annotation import are error
Related
All my android studio file is not showing original code. All java and XML file affected. When I open a file it shows "File was loaded in the wrong encoding:'UTF-8'. I tried to reload in another coding but problem not resolved. I can see code in Notepad but not in android studio.
CustomApplication.java Original Code showing in Notepad
package satlaa.desijewellery.utils;
import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
public class CustomApplication extends Application {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocaleHelper.onAttach(base, "hi"));
}
}
In Android Studio
AAPT , �
&layout/abc_alert_dialog_title_material
"�C:\Users\Anjaan\.gradle\caches\transforms-1\files-1.1\appcompat-v7-
27.1.1.aar\11bca4c6723b60847116b8b51872d16b\res\layout\abc_alert_dialog_title_m
aterial.xml*
id/alertTitle-*
id/titleDividerNoCustom8*
id/title_template*
id/topPanel
�
9
android*http
I can even set here as code.
Go to :
File -> Other Settings -> Default Settings, find File Encodings, change Project Encoding to System-Default and the other settings as follows:
If this didn't help, try reinstalling the Android Studio (or install the latest version if you already don't use it).
I have include a jar file in my android project. Inside the jar file there is a class OverlayView in a package name android.widget. I can import the class into my Test.java file by import android.widget.OverlayView; and call the method init(). After these I can compile successfully. But while running the app it throws an exception
java.lang.NoSuchMethodError: android.widget.OverlayView.init
I didnt get class definition error
Your library contains android.widget? There is already a package with android.widget as its name. My guess is that it's conflicting with your library. Try deleting the import statements, by this time you should get an error because you deleted the import. Place your cursor in the method that has error then wait for the import suggestion to pop out, then alt+enter to import package. See if it is conflicting with the default android.widget package.
We are trying to use the Robolectric testing framework in Android Studio in order to test the Facebook API. The Facebook Login button works so the Facebook API is working. However, the following test fails:
package com.airportapp.test.Models;
import android.app.Activity;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.Robolectric;
import com.airportapp.test.MyRobolectricTestRunner;
import com.airportapp.LoginActivity;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
#RunWith(MyRobolectricTestRunner.class)
public class LoginActivityTest {
#Before
public void setup() {
//do whatever is necessary before every test
}
#Test
public void testActivityFound() {
Activity activity = Robolectric.buildActivity(LoginActivity.class).create().get();
Assert.assertNotNull(activity);
}
}
And the error is that Android Studio could not find the android.support file when we run the tests. You can see the error here:
The other error that shows up is:
android.view.InflateException: XML file app/src/main/res/layout/activity_login.xml line #-1 (sorry, not yet implemented): Error inflating class com.facebook.widget.LoginButton
So Android Studio is not happy with the facebook login button as well :( But it works... We think that we need to import something, but we don't know where to put it.
The InflateException is because Robolectric cannot find the resources from the Facebook SDK. To solve this, the project.properties file has to be updated to point to the Facebook SDK project. Do this by adding the following line to it:
android.library.reference.1={Path}
{Path} should be a relative path, from the project.properties file to the folder containing the AndroidManifest.xml of the Facebook SDK project. In my case that is ../../build/intermediates/exploded-aar/com.facebook.android/facebook/3.21.0.
Note that this works for all Android Library Projects which contain resources that aren't found by Robolectric. Further reading: here and here. Also, more documentation about project.properties can be found here. Note that in my project the Robolectric tests are located in the Android app project itself. So you could also try placing the project.properties file in the same directory as the AndroidManifest.xml used for testing.
As for your first problem; I have no personal experience with it. But it appears to be because Gradle cannot find the support libraries when compiling the unit tests. The answer from this question should fix it.
I'm trying to figure out a way to share code across projets. this is what i did
created a project called sharecode and made the following class
package codelib.com;
public class cShape {
}
made a android project called testsharecode
whent to properties->java build path and clicked on projects at the top.
clicked add, and added sharecode
created a class to try include the cShape class from the sharecode project
package com.example.testsharecode;
import codelib.com
public class parent {
cShape test;
}
On my import i get a error saying
"only a type can be imported, cadelib resolves to a package"
on cShape i get a error saying the def does not exist.
How can project testsharecode use the code in projetc sharecode?
have you tried the following method :
right click on the distination projet, Build Path -> configure build path
chose project then select testsharecode
back in your distiation project now you should be able to use your public classes.
hope this helps
i'm triing to use this directory picker: Android-DirectoryChooser
if i import it in eclipse like: file -> import -> existing and. proj. -> directory picker -> library and sample project
it gives this errors:
what am i doing wrong?or how to implement it in the right way?
errors:
The declared package "net.rdrei.android.dirchooser" does not match the expected package "main.java.net.rdrei.android.dirchooser"
Change the package name at top of the class ,It is the starting statement of your class and your own package ,where your getting the error right click on that you will have your own package...