Closed Cese93 closed 8 years ago
The part new TmdbApi("Myapikey");
is wrong because "Myapikey" doesnt refer to anything.
You have to get an API key from themoviedb website and either place it there or place it in your strings.xml en refer to it
i do this but the problem still persist.
Do you know what is that error? It's another error
FATAL EXCEPTION: main
Process: com.example.erik_.tvmanager, PID: 12932
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.erik_.tvmanager/com.example.erik_.tvmanager.MainActivity}: info.movito.themoviedbapi.tools.MovieDbException: Failed to read configuration
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: info.movito.themoviedbapi.tools.MovieDbException: Failed to read configuration
Android does not allow to access the network from your main thread. Just google for NetworkOnMainThreadException and you'll find more details and workarounds.
i got this error:
02-04 14:24:01.984 22993-22993/com.example.erik_.tvmanager E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.erik_.tvmanager, PID: 22993 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.erik_.tvmanager/com.example.erik_.tvmanager.MainActivity}: info.movito.themoviedbapi.tools.MovieDbException: Failed t read configuration at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: info.movito.themoviedbapi.tools.MovieDbException: Failed to read configuration at info.movito.themoviedbapi.TmdbApi.<init>(TmdbApi.java:48) at info.movito.themoviedbapi.TmdbApi.<init>(TmdbApi.java:35) at com.example.erik_.tvmanager.MainActivity.onCreate(MainActivity.java:42) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273) at java.net.InetAddress.lookupHostByName(InetAddress.java:431) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252) at java.net.InetAddress.getAllByName(InetAddress.java:215) at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29) at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:188) at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:157) at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:100) at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:357) at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:340) at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330) at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:384) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getHeaders(HttpURLConnectionImpl.java:150) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getHeaderFields(HttpURLConnectionImpl.java:210) at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getHeaderFields(DelegatingHttpsURLConnection.java:178) at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getHeaderFields(HttpsURLConnectionImpl.java) at info.movito.themoviedbapi.tools.WebBrowser.readHeader(WebBrowser.java:226) at info.movito.themoviedbapi.tools.WebBrowser.request(WebBrowser.java:143) at info.movito.themoviedbapi.tools.WebBrowser.request(WebBrowser.java:112) at info.movito.themoviedbapi.TmdbApi.requestWebPage(TmdbApi.java:64) at info.movito.themoviedbapi.AbstractTmdbApi.mapJsonResult(AbstractTmdbApi.java:58) at info.movito.themoviedbapi.AbstractTmdbApi.mapJsonResult(AbstractTmdbApi.java:45) at info.movito.themoviedbapi.AbstractTmdbApi.mapJsonResult(AbstractTmdbApi.java:40) at info.movito.themoviedbapi.TmdbConfig.getConfig(TmdbConfig.java:18) at info.movito.themoviedbapi.TmdbApi.<init>(TmdbApi.java:44) at info.movito.themoviedbapi.TmdbApi.<init>(TmdbApi.java:35) at com.example.erik_.tvmanager.MainActivity.onCreate(MainActivity.java:42) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I have this in my MainActivity.
The error says that api_key can't be empty, what does it means? Can you help me?