步骤获得SignalR Android Studio中工作 [英] Steps to get SignalR working in Android Studio

查看:948
本文介绍了步骤获得SignalR Android Studio中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想带来的 SignalR 进入我的 Android的工作室项目。

I'm trying to bring SignalR into my Android Studio project.

我成功地遵循在<一个教程href=\"http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr\">getting开始与SignalR 的,所以现在我有一个工作中心。在教程中的客户端是JavaScript和我得到了它在我的Andr​​oid手机上PC和我的家庭局域网工作确定在一个网页(在Chrome)通过WiFi。

I successfully followed the tutorial on getting started with SignalR, so now I have a working Hub. The client in that tutorial is javascript, and I got it working ok in a web page (in Chrome) on PC AND on my Android phone over WiFi on my home LAN.

然后我就去拿到Android的Java客户端的工作。我已经有Android Studio中的Andr​​oid应用程序的项目,我想使谈话到工作集线器作为测试,作为下一个步骤。

Then I went to go get the Android java client working. I already had an Android app project in Android Studio, which I want to make talk to that working Hub as a test, as the next step.

我下载了微软官方的Java为Android客户端作为拉链。

I downloaded the official Microsoft java client for Android, as a zip.

然后我提取并加载它作为一个项目进入Android的工作室。它建立没有任何错误。

Then I extracted it and loaded it as a project into Android Studio. It builds with no errors.

问题1:本项目只给我一个AAR,而不是一个JAR。我已经想通了如何使用Android Studio中一个罐子里,所以如果有一种方式来创建在这个节骨眼上一罐,我也许可以使这项工作。

Problem #1: This project only gives me an AAR, not a JAR. I have figured out how to use a jar in Android Studio, so if there's a way to create a jar at this juncture, I can probably make this work.

在这一点上我包括依赖到我的应用程序的项目。该readme.md说为:

At this point I included the dependencies into my app project. The readme.md says to:

添加signalr-客户sdk.jar,signalr客户端-SDK-的android.jar GSON
  库作为依赖的gradle到项目。

Add the signalr-client-sdk.jar, signalr-client-sdk-android.jar gson library as a gradle dependency to the project.

所以我试图尽可能地遵循。从我的build.gradle这里是:

so I tried to follow that as closely as possible. Here's from my build.gradle:

compile 'com.google.code.gson:gson:2.3.1'
compile files('libs/signalr-client-sdk.jar')
compile files('libs/signalr-client-sdk-android-release.aar')

问题2:有进口AAR作为一个模块到Android Studio中我的应用程序的项目,它仍然没有看到必要的命名空间,以使主语句的工作。这里是主要的陈述(SignalR在Android上的hello world,编译明智):

Problem #2: Having imported the aar as a module into my app project in Android Studio, it still does not see the necessary namespace to make the primary statement work. Here is the primary statement (the hello world of SignalR in Android, compiler-wise):

Platform.loadPlatformComponent(new AndroidPlatformComponent());

起初它没有拿起任何东西,那么它捡起进口microsoft.aspnet.signalr.client.Platform; 平台。它仍然没有什么线索,以导入 AndroidPlatformComponent ,所以我坚持,直到我能过去,这

At first it wasn't picking up anything, then it picked up import microsoft.aspnet.signalr.client.Platform; for Platform. It still does not have a clue what to import for AndroidPlatformComponent, so I'm stuck until I can get past this.

如你所知有很多Android Studio中的文件,我不希望只喷出他们都在这里之前,我知道你想看到哪些文件。如果你告诉我你想看到哪些文件,我会加入他们作为编辑。

As you know there are a lot of files in Android Studio, and I don't want to just spew them all out here before I know which files you want to see. I'll add them as an edit if you tell me which files you want to see.

推荐答案

那么你可以从这个jar文件的链接

Well you can download the jar files from this link

第1步

你的包内创建一个libs文件夹,只是这里粘贴这些jar文件。

Create a libs folder inside your package and simply paste these jar files here.

第2步

现在加入编译文件的build.gradle内依赖

Now add "compile files" inside dependencies of build.gradle

现在这个preSS后同步工程与摇篮文件

Now after this press "Sync Project with Gradle file"

第3步

即使同步和导入罐子成功仍然面临一些进口错误等后
现在尝试的时候,它会被罚款和进口的所有类

Even after syncing and importing jar successfully you still face some import errors etc. Now try Invalidate cache and restart.After couple of times it will be fine and imports all the classes

第四步

现在您将看到Platform.loadPlatformComponent进口();没有任何问题。

Now you will see the imports for Platform.loadPlatformComponent(); without any problems


这篇关于步骤获得SignalR Android Studio中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆