简体   繁体   中英

Why can't I see android.support.v7 files?

I'm trying to do the demo for the new Cast SDK (for using Chromecast), but I'm having trouble. I downloaded a demo for Android, and I'm getting errors in my project when trying to import anything from android.support.v7 library.

If I try to import from android.support.v4 or android.support.v13, things show up, but nothing shows up when I try to import from android.support.v7. It seems as if I don't have these files, but when I open the Android SDK Manager, it seems that I have most things installed (Android 3.0 API 11 and above).

Does anyone know why I might be missing this, or how to get it up and running?

Here are the files that I need to import for my demo:

import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.MediaRouteActionProvider;
import android.support.v7.media.MediaRouteSelector;
import android.support.v7.media.MediaRouter;
import android.support.v7.media.MediaRouter.RouteInfo;

If you wants to integrate actionbar below android sdk 3.x use given link reference: Android Demo: http://developer.android.com/tools/support-library/features.html

"uses-sdk android:minSdkVersion="7"

Support Library classes that provide support for android sdk 2.x and above.

public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    getSupportActionBar().setTitle("ActionBar Support Demo");
}

}

http://www.coderzheaven.com/tag/android-support-v7-appcompat-jar/

There are multiple v7 libraries: appcompat, mediarouter and gridlayout. Follow the steps here to import and set them up (use Android Libraries with Resources); you need to install appcompat first and then mediarouter and make sure the mediarouter library lists appcompat as part of its dependency.

If you have already downloaded libraries, it will be present in android-sdk at following location.

android-sdk\\extras\\android\\support\\v7\\mediarouter\\libs\\android-support-v7-mediarouter.jar

similarly include other jars as well from follwing folder.

android-sdk\\extras\\android\\support\\v7

add these jars in your android project inside libs folder.

I fixed the import of MediaRouter by adding this line into the dependencies inside the build.gradle file:

compile 'com.android.support:mediarouter-v7:21.0.3'

Android Studio imports that as a library so there won't be any troubles with the resources at all.

You need to download and install Android Support Repository using the SDK Manager in Android Studio. After that add the dependencies inside the build.gradle file as shown below

dependencies {    
'compile com.android.support:mediarouter-v7:25.0.0'
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM