I am new to developing on Android Studio, my app was running fine until the studio exited abruptly after that the project cannot find any of the libraries imported (in asterisks) like Uri, AppCompatActivity etc to my AppCompatActivity class (I am using Android 2.1.2)
import android.net.*Uri*;
import android.os.*Bundle*;
import android.support.v7.*;
import android.util.*Log*;
import android.view.*View*;
import android.widget.*AdapterView*;
import android.widget.*ListView*;
import com.google.android.gms.appindexing.*Action*;
import com.google.android.gms.appindexing.*AppIndex*;
import com.google.android.gms.common.api.*GoogleApiClient*;
import org.xmlpull.v1.*XmlPullParser*;
import org.xmlpull.v1.*XmlPullParserException*;
import org.xmlpull.v1.*XmlPullParserFactory*;
import java.io.*IOException*;
import java.io.*InputStream*;
import java.util.*ArrayList*;
import java.util.*List*;
public class Menu extends android.support.v7.app.*AppCompatActivity* {
What I have tried uptil now:
checked projectstructure -> app -> dependencies
tried sequencing the libs
com.android.support:appcompat-v7:24.2.1
com.google.android.gms:play-services-appindexing:8.1.0
before junit:junit:4.12
Checked build.gradle and added above 2 dependencies
Clean Project
Build APK
ReBuild Project (many times)
P.S: com.google.android... imports were auto generated with onstart and onstop overrides (no idea why)
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
P.S: My Android Studio is installed in C:/Programfiles and my project is saved in a different location under AndroidStudioProjects folder
Related
My Android Studio Project (migrated to AndroidX) (TheInstrumentals) automatically imports android.app.Fragment whenever I make a Fragment from Android Studio's Fragment Wizard. How can I make it auto-import androidx.fragment.app.Fragment?
I've tried making a new Blank Fragment from another project (ViewPagerTest) (also migrated to AndroidX) and it imports androidx.fragment.app.Fragment automatically instead of the deprecated android.app.Fragment.
My other project (Udacity Project) (not in AndroidX) automatically imports android.support.v4.app.Fragment when the same thing was done.
com.mydomain.theinstrumentals.BlankFragment.java:
package com.mydomain.theinstrumentals;
import ...
import android.app.Fragment; //imported automatically
import ...
public class BlankFragment extends Fragment /*Fragment was strikedthrough */ {...}
com.mydomain.viewpagertest.BlankFragment.java:
package com.mydomain.viewpagertest;
import androidx.fragment.app.Fragment; //imported automatically
import ...
public class BlankFragment extends Fragment {...}
com.example.android.miwok.NumbersFragment:
package com.example.android.miwok.NumbersFragment;
import ...
import android.support.v4.app.Fragment; //imported automatically
import ...
public class NumbersFragment extends Fragment {...}
My answer to the linked post isn't old - the imports are still alphabetical and the options to auto import are modifiable in the settings
Short answer - AndroidX is extra, and later on the classpath, not on the core API, therefore it's listed later in the import menu
Plus, the Fragment wizard uses internal template files for creating new classes for all components, and can't assume that you have AndroidX as part of your code. If it did, then it would have to insert those plugins into the Gradle build, for example
I get the following error log when I run my Android app: http://pastebin.com/1jHEfdQ3 The app sometimes crashes in the simulator but most of the time it just displays a white screen. I can console.log one or two things until the app won't respond. R-R to refresh doesn't work. None of the dev tools work. I'm stumped with what to do at this point.
I'm running react native 0.38.0
EDIT:
I've tried cleaning my gradle and deleting and reinstalling my node modules.
One thing to note is that I am using React Native Navigation which means I had to modify MainApplication and MainActivity to the following:
MainActivity:
package com.prayerrequest;
import com.facebook.react.ReactActivity;
import com.reactnativenavigation.NavigationApplication;
import com.airbnb.android.react.maps.MapsPackage;
import com.cmcewen.blurview.BlurViewPackage;
import io.realm.react.RealmReactPackage;
import com.reactnativenavigation.controllers.SplashActivity;
public class MainActivity extends SplashActivity {
}
MainApplication:
package com.prayerrequest;
import com.facebook.react.ReactPackage;
import com.cmcewen.blurview.BlurViewPackage;
import io.realm.react.RealmReactPackage;
import com.airbnb.android.react.maps.MapsPackage;
import com.reactnativenavigation.NavigationApplication;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends NavigationApplication {
#Override
public boolean isDebug() {
// Make sure you are using BuildConfig from your own application
return BuildConfig.DEBUG;
}
#Override
public List<ReactPackage> createAdditionalReactPackages() {
return Arrays.<ReactPackage>asList(
new RealmReactPackage(),
new BlurViewPackage(),
new MapsPackage()
);
}
}
I've crossposted on React Native's issues page here
The issue seems to be 'Couldn't load memtrack module (No such file or directory)'
It looks like there's an issue with the simulator.
This is a config of my fully functional simulator:
Lots of other suggestions can be found here:
Couldn't load memtrack module Logcat Error
I had a similar problem. I would get this white screen when trying to get it to run on device.
The problem was when I would do adb devices or react-native run-android I would get "ADB is Not Recognized as an internal or external command".
So my fix was to add the path to adb.exe's parent directory to my Environment Variables and then restart my command prompts.I then ran react-native run-android and on startup no more red screen showing the completely useless error message Error calling AppRegistry.runApplication! :)
So I found ADB was located in my folder:
C:\Users\dell\AppData\Local\Android\sdk\platform-tools\adb.exe
I am on a Windows 10 system. dell is my user name of the computer.
So I went to System Environment Variables then found "Path" then clicked "Edit", then clicked "New" and added in "C:\Users\dell\AppData\Local\Android\sdk\platform-tools".
should I use google drive bat I can't compile this activity
package com.google.android.gms.drive.sample.demo;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
/**
* An abstract activity that handles authorization and connection to the Drive
* services.
*/
public abstract class BaseDemoActivity extends Activity implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
...
I use Google Plugin for Eclipse to install the library and google APIs
but since compile error
GoogleApiClient cannot be resolved to a type
Follow the Google+ Platform Quickstart for Android in order to install Google Play Services as a library project.
In particular see step 5:
5. Import the Google Play Services library project.
Select File > Import > Android > Existing Android Code Into Workspace and click Next.
Select Browse.... Enter <android-sdk-folder>/extras/google/google_play_services/.
Select google-play-services_lib. Click Finish to import.
I want to use android wheel to choose from some items. I just downloaded some library code from google. I am using it in my app, but it is giving some error.
import kankan.wheel.widget.OnWheelChangedListener;
import kankan.wheel.widget.OnWheelScrollListener;
import kankan.wheel.widget.WheelView;
import kankan.wheel.widget.adapters.AbstractWheelTextAdapter;
import kankan.wheel.widget.adapters.ArrayWheelAdapter;
Giving following error:
The import kankan.wheel.widget cannot be resolved
Can anyone tell me why this error is coming.
Thanks.
I have also used that library in my code and it is working fine.
possibility of error
You can't configure lib properly
In build path add lib
Clean eclipse.
Restart eclipse
import kankan.wheel.widget.OnWheelChangedListener;
import kankan.wheel.widget.OnWheelScrollListener;
import kankan.wheel.widget.WheelView;
import kankan.wheel.widget.adapters.NumericWheelAdapter;
WheelView wheel = getWheel(id);
Right now I am able to get access to the hidden and internal android APIs, but now I want access to things like AlarmManagerService which is in server. I used adb pull system/framework/services.jar changed services.jar to services.zip which unpacked a directory of all the server classes (including AlarmManagerService which I was looking for). My question now is how can I add those server classes to my android.jar file which I can then use in Eclipse?
I hope that makes sense the way I worded it. Let me know if there is any confusion I can clear up.
EDIT: Essentially, when all is said and done, I want to be able to do something like below without any errors:
import com.android.server.AlarmManagerService;
public class TestActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AlarmManagerService ams = new AlarmManagerService(this.getApplicationContext());
ams.setTime(1313);
}
}
ANOTHER EDIT:
I figured this out after looking at all the source code.
Classes like AlarmManagerService just have package visibility which is why it cannot be imported. Some classes are public, but many other com.android.server classes have package constructors so they can't be instantiated.
Here are the com.android.server.* I was able to import and successfully create an object of:
import com.android.server.AttributeCache;
import com.android.server.BootReceiver;
import com.android.server.BrickReceiver;
import com.android.server.ClipboardService;
import com.android.server.ConnectivityService;
import com.android.server.DevicePolicyManagerService;
import com.android.server.DiskStatsService;
import com.android.server.DropBoxManagerService;
import com.android.server.EntropyService;
import com.android.server.InputMethodManagerService;
import com.android.server.LocationManagerService;
import com.android.server.MasterClearReceiver;
import com.android.server.NativeDaemonConnectorException;
import com.android.server.NetStatService;
import com.android.server.NotificationPlayer;
import com.android.server.ProcessMap;
import com.android.server.ProcessStats;
import com.android.server.SystemBackupAgent;
import com.android.server.SystemServer;
import com.android.server.ThrottleService;
import com.android.server.TwilightCalculator;
import com.android.server.Watchdog;
import com.android.server.connectivity.Tethering;
import com.android.server.status.AnimatedImageView;
import com.android.server.status.CloseDragHandle;
import com.android.server.status.DateView;
import com.android.server.status.ExpandedView;
import com.android.server.status.IconMerger;
import com.android.server.status.LatestItemView;
import com.android.server.status.NotificationData;
import com.android.server.status.NotificationLinearLayout;
import com.android.server.status.StatusBarService;
import com.android.server.status.StatusBarView;
import com.android.server.status.StorageNotification;
import com.android.server.status.TickerView;
import com.android.server.status.TrackingPatternView;
import com.android.server.status.TrackingView;
import com.android.server.status.UsbStorageActivity;
android.jar contains only the public API's class files and I think you made changes in 'com.android' package or its internal packages. So to reflect the changes in eclipse you have to add the path explicitly to your service.jar to your project. But remeber this will not reflected at run time, since the emulator or the device you are using have not been updated your changes. And you can't update them by simply modifying the jar file, since the device or emulator uses the image 'system.img' which internally have .dex file as library not the .jar file for internal APIs. To make changes for device/emulator you have to build the whole code and for that you can refer the http://source.android.com/source/index.html.