android / architecture-components-samples Goto Github PK
View Code? Open in Web Editor NEWSamples for Android Architecture Components.
Home Page: https://d.android.com/arch
License: Apache License 2.0
Samples for Android Architecture Components.
Home Page: https://d.android.com/arch
License: Apache License 2.0
Is possible to share same instance of view model between activities similar to share same view model between fragments?
C:\Users\pdog18\Desktop\android-architecture-components-master\BasicSample\app\src\main\java\com\example\android\persistence\db\AppDatabase.java
Error:(31, 17) 警告: Schema export directory is not provided to the annotation processor so we cannot export the schema. You can either provide `room.schemaLocation` annotation processor argument OR set exportSchema to false.
AppDatabase
/*
* Copyright 2017, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.persistence.db;
import android.arch.persistence.room.Database;
import android.arch.persistence.room.RoomDatabase;
import android.arch.persistence.room.TypeConverters;
import com.example.android.persistence.db.dao.CommentDao;
import com.example.android.persistence.db.dao.ProductDao;
import com.example.android.persistence.db.entity.CommentEntity;
import com.example.android.persistence.db.entity.ProductEntity;
import com.example.android.persistence.db.converter.DateConverter;
@Database(entities = {ProductEntity.class, CommentEntity.class}, version = 1)
@TypeConverters(DateConverter.class)
public abstract class AppDatabase extends RoomDatabase {
static final String DATABASE_NAME = "basic-sample-db";
public abstract ProductDao productDao();
public abstract CommentDao commentDao();
}
Like title,I wanna clear table,or delete data by sql ,but I can't find any way
I just cloned the repo and attempted to build on the command-line via ./gradlew build
.
The problem is that Okio references java.nio.file
, which is not present in Android (prior to O, that is). I guess the simplest fix would be to disable InvalidPackage
, which seems to work for me.
How can I use databinding into viewmodel? I mean viewmodel as handler actions and change livedata in actions. Thanks for help.
Hi,
I would like to know if there are any plans to add an MVP sample to the repository. Thanks in advance!
In BasicSample project missed package com.example.android.persistence.databinding. It`s refferenced from com.example.android.persistence.ui.CommentAdapter
https://github.com/googlesamples/android-architecture-components/blob/master/GithubBrowserSample/app/src/main/res/layout/search_fragment.xml#L30
Error:Execution failed for task ':app:dataBindingProcessLayoutsDebug'.
org.xml.sax.SAXParseException; systemId: file:/D:/workspace/GithubBrowserSample/app/build/intermediates/data-binding-layout-in/debug/layout/search_fragment.xml; lineNumber: 30; columnNumber: 33; The value of attribute "type" associated with an element type "variable" must not contain the '<' character.
Android Studio 3.0 Canary 1
Hi guys,
I can't find an example of how to handle a situation when a callback needs to be dispatched from a global object that lives in Application scope.
Given the potential multiplicity of Lifecycles involved, is this possible at all?
I would like to refactor this code to use Lifecycles:
public class MyActivity extends Activity implements UserStateManagerListener {
private UserStateManager mUserStateManager;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
mUserStateManager = ((MyApplication)getApplication()).getUserStateManager();
}
@Override
protected void onStart() {
super.onStart();
mUserStateManager.registerListener(this);
}
@Override
protected void onStop() {
super.onStop();
mUserStateManager.unregisterListener(this);
}
@Override
public boolean onUserStateChanged(UserState userState) {
...
}
}
P.S. I also opened similar issue in googlecodelabs: android/codelab-android-lifecycles#12
I have a POJO set up for use with Room and retrofit
@TypeConverters(DateConverter.class)
@Entity(indices = {@Index("code")})
public class HealthcareCenter {
@PrimaryKey
@SerializedName("id")
private int id;
@SerializedName("code")
private String code;
@SerializedName("name")
private String name;
@SerializedName("address")
private String address;
@SerializedName("phone")
private String phone;
@SerializedName("email")
private String email;
@ColumnInfo(name = "visited_date")
@SerializedName("visited_date")
private Date visited_date;
.... //Getters and setters omitted here
}
And have the following method in my Dao
@Query("select * from HealthcareCenter where code = :code")
LiveData<HealthcareCenter> getCenterbyCode(String code);
However when using
db.healthcareCenterDao().getCenterByCode(code).getValue()
the method returns null.
As a workaround I am omitting the LiveData when I want to retrieve the value once and want to update it (Using an observer leads to a loop).
Dao
@Query("select * from HealthcareCenter where code = :code")
HealthcareCenter getNonObservableCenterbyCode(String code);
Use
HealthcareCenter healthcareCenter = db.healthcareCenterDao().getNonObservableCenterbyCode(qrCode.getCenter_code());
Error:Failed to complete Gradle execution.
Cause:
The version of Gradle you are using (3.4.1) does not support the forTasks() method on
BuildActionExecuter. Support for this is available in Gradle 3.5 and all later versions.
Step to Reproduce:
Click the green arrow to build and run the APP
Im getting Application Install Fail error i have tried device and emulator.
i got this couple of waring in messages. (GithubBrowserSample)
Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources]
Warning:Supported source version 'RELEASE_7' from annotation processor 'android.arch.persistence.room.RoomProcessor' less than -source '1.8'
/Users/shanuka/android-architecture-components/GithubBrowserSample/app/src/main/java/com/android/example/github/db/GithubDb.java
Warning:(33, 17) Schema export directory is not provided to the annotation processor so we cannot export the schema. You can either provide `room.schemaLocation` annotation processor argument OR set exportSchema to false.
Warning:Supported source version 'RELEASE_7' from annotation processor 'android.arch.lifecycle.LifecycleProcessor' less than -source '1.8'
Error:Failed to resolve: android.arch.lifecycle:extensions:1.0.0-alpha1
Error:Failed to resolve: annotationProcessor
i cann't access https://maven.google.com
Error:Failed to resolve: Could not resolve android.arch.lifecycle:runtime:1.0.0-alpha1.
mBinding = DataBindingUtil.inflate(inflater, R.layout.product_fragment, container, false);
You store the binding into a field and never null it out. AFAIK this will leak the activity context.
In Reactive java we use observable.zip() for combine n numbers of API call or methods result into one .
In LiveData , How we achive this , Any sample code is avilable ?
compile "android.arch.lifecycle:runtime:1.0.0-alpha1"
compile "android.arch.lifecycle:extensions:1.0.0-alpha1"
annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha1"
in China, all above can not build success.can you apply some realse jar for us
android.support.test.espresso.AppNotIdleException: Looped for 2926 iterations over 60 SECONDS. The following Idle Conditions failed .
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:580)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:92)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:56)
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
at android.support.test.espresso.ViewInteraction.check(ViewInteraction.java:158)
at com.android.example.github.ui.repo.RepoFragmentTest.testError(RepoFragmentTest.java:130)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at android.support.test.internal.statement.UiThreadStatement.evaluate(UiThreadStatement.java:55)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:270)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1879)
In my view I have button which start recording audio I want to ask user to grant permission when user click on the button.
For example: How to ask permission for fine localization in BasicExample?
There is always the case: the user could not torrent the slow data loading process, and want to cancel it.
But in the sample project, I cannot find there is any method to meet that demand.
So, is there any way to achieve that goal?
The
cancel data loading
means:
When the user perform the cancel action, such asonBackPressed
, theNetworkBoundResource
need to cancel the ongoing db loading transaction and the network request
First off, the concept of having LiveData (and MutableLiveData) with observers that handle Lifecycle is a great addition on top of the bare metal Android components.
Having played around with LiveData and Observer there arrived one case where it would really be desirable to know if LiveData is passing on a cached version (mVersion
) due to the change of LifecycleBoundObserver (initiator
), this references the filed/param names in LiveData.java
.
Following here is a case where it would be good to know if LiveData is cached or not:
It seems to be a good pattern to create LiveData that is private final
and associate a getter with it, looks usually something like below:
private final MutableLiveData<ApiResponse<DownloadResponse>> mDownloadLiveData = new MutableLiveData<>();
A Fragment would then register an Observer on that LiveData
mViewModel.getDownloadLiveData().observe(this, mDownloadObserver);
mDownloadObserver
in this case would also be private final inside Fragment
private final mDownloadObserver = new Observer ...
So far so good, the Code will notify the Observer when new data arrives and consider the applications Lifecycle.
However, as soon as the Fragment undergoes a configuration change, LiveData realizes that LifecycleBoundObserver
has changed and mVersion
does not match observer.lastVersion
(in fact it has been initialized to -1) and thus publishes it's underlying data mData
with onChanged
.
I am certain this is how it is intended, and indeed it seems that most applications expect this behavior. However in certain cases it would be desirable to know that the onChange
has been fired with LifecycleBoundObserver.lastVersion = -1
.
Of course placing a state variable in the Fragment would allow for checking if the Data has been manually requested, yet it seems to negate the purpose of the stateless design around the Architecture components.
A suggestion would be to have a second option that allows to register a stateful Observer knowing if the callback is issued due to a new LifeCycleBoundObserver.
public void observe(LifecycleOwner owner, StatefulObserver<T> observer)
and
public interface StatefulObserver<T> {
/**
* Called when the data is changed.
* @param t The new data
* @param fromCache whether or not the value is submited due to a new LifeCycleBoundObserver
*/
void onChanged(@Nullable T t, boolean fromCache);
}
Again thanks a lot and keep up the good work!
Manuel
Im not sure if this is a "Bug", but after days of debugging, using several dagger architectures and so on i figured out why room throws the error
error: Entities and Pojos must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type).
I was not able to find the error using gradle. Even after using verbose assembleDebug there was no way to figure out why its just throwing a bunch of errors.
The reason for the error was, that i have in one Entitity
public class MyClass {
@Embedded private List<Condition> conditions;
}
@TypeConverter public static List<Condition> stringToConditionList(String data) {
return GsonUtil.gson().fromJson(data, new TypeToken<List<Condition>>() {
}.getType());
}
@TypeConverter public static String fromConditionList(List<Condition> data) {
return GsonUtil.gson().toJson(data);
}
Since i have created a typeconverter which converts to string and back, its of course not possible to have embedded classes. Anyway, it was not possible to find any way to get the proper location for this.
Please help, I have viewpager with fragments, databinding into viewmodel. Where I need use setCurrentItem and add functions of viewpager's adapter (view or viewmodel-databinding)? Is it necessary to create viewmodel for every viewpager's item?
Thanks for help.
I have used room for https://newsapi.org , i have problem in saving Articles which consists of List of Articles and Top Response Object has Source Detail.
{
"status": "ok",
"source": "the-next-web",
"sortBy": "latest",
-"articles": [
-{
"author": "TNW Deals",
"title": "Build for the web of the future with the Perfect Python Programming Bundle — for under $25",
"description": "If you’d like to elbow your way into the ranks of professional web development, you may want to seriously consider mastering Python as one of your go-to coding tools. It’s easy ...",
"url": "https://thenextweb.com/offers/2017/06/11/build-web-future-perfect-python-programming-bundle-25/",
"urlToImage": "https://cdn3.tnwcdn.com/wp-content/blogs.dir/1/files/2017/06/vkUK1Nd.jpg",
"publishedAt": "2017-06-11T17:33:12Z"
},
-{
"author": "Alice Bonasio",
"title": "Can SnoreTech Save my Marriage?",
"description": "I don’t know what Donald Trump’s excuse is, but whenever I find myself tweeting something incoherent at around 3 in the mornings it’s usually because my husband’s snoring has ...",
"url": "https://thenextweb.com/contributors/2017/06/11/can-snoretech-save-marriage/",
"urlToImage": "https://cdn2.tnwcdn.com/wp-content/blogs.dir/1/files/2017/06/527px-PSM_V11_D725_Head_brace_to_eliminate_snoring.jpg",
"publishedAt": "2017-06-11T15:16:58Z"
}]
}
want persists Articles Response and Articles in 2 Tables i.e @Embedded but its a problem and also periodically update the new News feed into Article Table.
As of now in my Github Repo i have used type converter to save articles as json and retrieve .
https://github.com/anil-gudigar/Twill
let me know how to do it?
Hi ,
From initial login , the origina data showed correctly. After that I have update something in web portal .
Again I have close the app , and reopen it showing the old data , not update the current one what I have seen in in my web portal.
An example would be
@Entity class Foo { @ColumnInfo var is_bar: Boolean = false }
Hi, It is actually dagger 2.10 specific question. But I think no problem to ask here.
My question is, what if you want to pass RepoView to your RepoViewModel? In my case I am using ViewModel. I am not using LiveData to observe. So I need to pass RepoView to RepoViewModel as parameter.
@Inject
public RepoViewModel(RepoRepository repository, RepoView repoView)
@Module
public class RepoModule {
@Provides
RepoView provideRepoView(RepoFragment repoFragment){
return repoFragment;
}
}
@ContributesAndroidInjector(modules = RepoModule.class)
abstract RepoFragment contributeRepoFragment();
I implemented it in this way but it gives me error compile time. It says that I didn't provide RepoView to inject RepoViewModel.
RepoView can not bi provided without @Provides-annotation method.
Am I missing something? @JoseAlcerreca @yigit
I am getting this error specifically by trying to use kotlin with Room, but I assume this would also occur if you are using Java 8 in your source code.
The error is: Warning:warning: Supported source version 'RELEASE_7' from annotation processor 'android.arch.persistence.room.RoomProcessor' less than -source '1.8'
and seems to be from a use of @SupportedSourceVersion
which specifies "the latest source version an annotation processor supports"? Is this expected? Do we need to wait for the full 1.0 release for it to be fully supported?
One of the most common content provider that is accessed is Android's MediaStore. How do I access data of Android MediaStore using Room?
GitHubBrowserSample
APP force close due to Unexpected end of stream on Connection while turning the phone with searching.
Note: The bug might be a Heisenbug.
Sometime it might not happen, but with a few tries, it will reproduce.
NullPointerException occurs when click on some search result in GithubBrowserSample
Error logs are as below.
05-27 11:41:53.363 21175-21175/com.android.example.github D/dagger.android.support: An injector for com.android.example.github.ui.repo.RepoFragment was found in com.android.example.github.MainActivity
05-27 11:41:53.437 21175-21175/com.android.example.github D/RepoRepository: rece contributor list from db: []
05-27 11:41:54.551 21175-21657/com.android.example.github E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1
Process: com.android.example.github, PID: 21175
java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
at com.android.example.github.repository.RepoRepository$3.saveCallResult(RepoRepository.java:135)
at com.android.example.github.repository.RepoRepository$3.saveCallResult(RepoRepository.java:132)
at com.android.example.github.repository.NetworkBoundResource.lambda$null$5$NetworkBoundResource(NetworkBoundResource.java:68)
at com.android.example.github.repository.NetworkBoundResource$$Lambda$3.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
--------- beginning of system
Isn't it easier to make GithubApp
extend DaggerApplication
and AppComponent
extend AndroidInjector<GithubApp>
? Or is there a purpose for not doing that?
Error:This Gradle plugin requires Studio 3.0 minimum
I download soucecode and try to run, but cannot.
How can I use viewmodel with databinding class? Thanks for help.
when I gradlew build the BasicSample, i got error
logs:
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
Could not resolve android.arch.persistence.room:support-db:1.0.0-alpha1.
Required by:
project :app > android.arch.persistence.room:runtime:1.0.0-alpha1
project :app > android.arch.persistence.room:runtime:1.0.0-alpha1 > android.arch.persistence.room:support-db-impl:1.0.0-alpha1
> Could not resolve android.arch.persistence.room:support-db:1.0.0-alpha1.
> Could not get resource 'https://dl.google.com/dl/android/maven2/android/arch/persistence/room/support-db/1.0.0-alpha1/support-db-1.0.0-alpha1.pom'.
> Could not HEAD 'https://dl.google.com/dl/android/maven2/android/arch/persistence/room/support-db/1.0.0-alpha1/support-db-1.0.0-alpha1.pom'.
> dl.google.com`
i don't think this is network error. because i has set proxy. who knows why
I just open BasicSample in android studio 2.3, with gradle-3.3
there is the error message:
Error:Conflict with dependency 'com.android.support:support-v4' in project ':app'. Resolved versions for app (21.0.3) and test app (25.3.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Project :app: Provided dependencies can only be jars. com.android.support:appcompat-v7:25.3.1@aar is an Android Library.
Error:Project :app: Provided dependencies can only be jars. com.android.support:animated-vector-drawable:25.3.1@aar is an Android Library.
Error:Failed to resolve: annotationProcessor
Error:Project :app: Provided dependencies can only be jars. com.android.support:support-vector-drawable:25.3.1@aar is an Android Library.
Error:Project :app: Provided dependencies can only be jars. com.android.support:cardview-v7:25.3.1@aar is an Android Library.
in Basic Sample, ProductFragment.java
// Observe product data
model.getObservableProduct().observe(this, new Observer<ProductEntity>() {
@Override
public void onChanged(@Nullable ProductEntity productEntity) {
model.setProduct(productEntity);
}
});
We observe for a change in LiveData<ProductEntity> mObservableProduct
. When a change is there we set ObservableField<ProductEntity> product
so that the data-binding library updates the UI. It seems like too much work perhaps.
My understanding would be that since LiveData cares about the lifecycle owner and not the view, hence databinding doesn't support LiveData. Is that so? @yigit
If this is the right way of doing it, is there any better way of using Data-Binding with LiveData?
onFragmentViewDestroyed
is being called even if the Fragment that is being destroyed is not the Holding Fragment. For Example - From the Base Fragment, open a DialogFragment
DialogFragment fragment = new SomeFragment();
fragment.show(getFragmentManager(), "tag");
On coming back from the Dialog Fragment, All AutoClearedView
instances will get cleared in the Base Fragment. add same instance check on the Fragment solves the issue
First of all I want to say thanks for the three samples which enlighten working with these new components significantly, looking at the code there is a lot to learn.
After trying to create a project, making use of the new arch components, I noticed that one of my Fragments received more and more events from LiveData within the Observer code after navigating back and forth in the UI.
This happens due to the Fragment instance being retained and popped back from the stack after "back" navigation.
In these examples typically in onActivityCreated
LiveData is observed and a new Observer is created. In order to solve recreating new Observers, checking if onActivityCreated
has been called on the instance of Fragment before seems to be the goto solution for the moment.
@yigit how would you go about this? check if savedInstanceState is null and then create Observers? I also noticed that declaring the Observers as final fields seems to solve the issue as well, meaning that registering the same Observer instance several times seems to be fine, is this something you would recommend?
Thanks a lot and keep up the good work!
Manuel
UPDATE 12 Oct 2019
using viewLifecycleOwner
as LifecycleOwner as proposed seems to solve my issue. Typically what I do now is the following:
class MainFragment : Fragment() {
// ... declare viewmodel lazy
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel.liveData.observe(viewLifecycleOwner, Observer { item ->
// ... code that deals with item / state goes here
})
}
//...
}
Should ViewModels communicate directly with services, or via repository?
The service is responsible for media streaming, and relies on external library.
How to best integrate Room with a Firebase database?
Should we subscribe to Firebase updates and write the received data into a local Room database as a persistent local cache that can notify our listeners?
When API requires registration and after that sign in process should we use a repo pattern for that?
What with another process like reset password?
How combine with OAuth api?
Kotlin's sealed classes are awesome. But as they do not have public constructors, I guess there is little chance of supporting them with Room. Any thoughts on this?
When I build Project the following error:
Failed to resolve: Could not resolve android.arch.core:core-testing:1.0.0-alpha1. Required by: project :app Open File
How to deal with it?
@yigit is it relatively simple to integrate your's android-priority-jobqueue with this new Arch Components? I am wondering where will be the ideal place to do the "async task" operation. Thanks in advance!
What kind of rules are needed for proguard?
Caused by: java.lang.RuntimeException: Cannot create an instance of class ***.login.k at android.arch.lifecycle.n$a.a(Unknown Source) at android.arch.lifecycle.m.a(Unknown Source) at android.arch.lifecycle.m.a(Unknown Source) at ***.LoginActivity.onCreate(Unknown Source)
Thanks for help.
I have a question for State and Event, why state are started and created when event are onPause or onStop? Why not State is Pause or Stop for more clearly?
Here is what I get when I run ./gradlew assembleDebug
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:releaseRuntimeClasspath'.
> Could not find android.arch.lifecycle:runtime:1.0.0-alpha.
Searched in the following locations:
file:/Users/sourabh/Library/Android/sdk/extras/m2repository/android/arch/lifecycle/runtime/1.0.0-alpha/runtime-1.0.0-alpha.pom
file:/Users/sourabh/Library/Android/sdk/extras/m2repository/android/arch/lifecycle/runtime/1.0.0-alpha/runtime-1.0.0-alpha.jar
file:/Users/sourabh/Library/Android/sdk/extras/google/m2repository/android/arch/lifecycle/runtime/1.0.0-alpha/runtime-1.0.0-alpha.pom
file:/Users/sourabh/Library/Android/sdk/extras/google/m2repository/android/arch/lifecycle/runtime/1.0.0-alpha/runtime-1.0.0-alpha.jar
file:/Users/sourabh/Library/Android/sdk/extras/android/m2repository/android/arch/lifecycle/runtime/1.0.0-alpha/runtime-1.0.0-alpha.pom
file:/Users/sourabh/Library/Android/sdk/extras/android/m2repository/android/arch/lifecycle/runtime/1.0.0-alpha/runtime-1.0.0-alpha.jar
https://jcenter.bintray.com/android/arch/lifecycle/runtime/1.0.0-alpha/runtime-1.0.0-alpha.pom
https://jcenter.bintray.com/android/arch/lifecycle/runtime/1.0.0-alpha/runtime-1.0.0-alpha.jar
https://maven.google.com/android/arch/lifecycle/runtime/1.0.0-alpha/runtime-1.0.0-alpha.pom
https://maven.google.com/android/arch/lifecycle/runtime/1.0.0-alpha/runtime-1.0.0-alpha.jar
https://repo1.maven.org/maven2/android/arch/lifecycle/runtime/1.0.0-alpha/runtime-1.0.0-alpha.pom
https://repo1.maven.org/maven2/android/arch/lifecycle/runtime/1.0.0-alpha/runtime-1.0.0-alpha.jar
Required by:
project :app
> Could not find android.arch.lifecycle:extensions:1.0.0-alpha.
Searched in the following locations:
file:/Users/sourabh/Library/Android/sdk/extras/m2repository/android/arch/lifecycle/extensions/1.0.0-alpha/extensions-1.0.0-alpha.pom
file:/Users/sourabh/Library/Android/sdk/extras/m2repository/android/arch/lifecycle/extensions/1.0.0-alpha/extensions-1.0.0-alpha.jar
file:/Users/sourabh/Library/Android/sdk/extras/google/m2repository/android/arch/lifecycle/extensions/1.0.0-alpha/extensions-1.0.0-alpha.pom
file:/Users/sourabh/Library/Android/sdk/extras/google/m2repository/android/arch/lifecycle/extensions/1.0.0-alpha/extensions-1.0.0-alpha.jar
file:/Users/sourabh/Library/Android/sdk/extras/android/m2repository/android/arch/lifecycle/extensions/1.0.0-alpha/extensions-1.0.0-alpha.pom
file:/Users/sourabh/Library/Android/sdk/extras/android/m2repository/android/arch/lifecycle/extensions/1.0.0-alpha/extensions-1.0.0-alpha.jar
https://jcenter.bintray.com/android/arch/lifecycle/extensions/1.0.0-alpha/extensions-1.0.0-alpha.pom
https://jcenter.bintray.com/android/arch/lifecycle/extensions/1.0.0-alpha/extensions-1.0.0-alpha.jar
https://maven.google.com/android/arch/lifecycle/extensions/1.0.0-alpha/extensions-1.0.0-alpha.pom
https://maven.google.com/android/arch/lifecycle/extensions/1.0.0-alpha/extensions-1.0.0-alpha.jar
https://repo1.maven.org/maven2/android/arch/lifecycle/extensions/1.0.0-alpha/extensions-1.0.0-alpha.pom
https://repo1.maven.org/maven2/android/arch/lifecycle/extensions/1.0.0-alpha/extensions-1.0.0-alpha.jar
Required by:
project :app
> Could not find android.arch.persistence.room:runtime:1.0.0-alpha.
Searched in the following locations:
file:/Users/sourabh/Library/Android/sdk/extras/m2repository/android/arch/persistence/room/runtime/1.0.0-alpha/runtime-1.0.0-alpha.pom
file:/Users/sourabh/Library/Android/sdk/extras/m2repository/android/arch/persistence/room/runtime/1.0.0-alpha/runtime-1.0.0-alpha.jar
file:/Users/sourabh/Library/Android/sdk/extras/google/m2repository/android/arch/persistence/room/runtime/1.0.0-alpha/runtime-1.0.0-alpha.pom
file:/Users/sourabh/Library/Android/sdk/extras/google/m2repository/android/arch/persistence/room/runtime/1.0.0-alpha/runtime-1.0.0-alpha.jar
file:/Users/sourabh/Library/Android/sdk/extras/android/m2repository/android/arch/persistence/room/runtime/1.0.0-alpha/runtime-1.0.0-alpha.pom
file:/Users/sourabh/Library/Android/sdk/extras/android/m2repository/android/arch/persistence/room/runtime/1.0.0-alpha/runtime-1.0.0-alpha.jar
https://jcenter.bintray.com/android/arch/persistence/room/runtime/1.0.0-alpha/runtime-1.0.0-alpha.pom
https://jcenter.bintray.com/android/arch/persistence/room/runtime/1.0.0-alpha/runtime-1.0.0-alpha.jar
https://maven.google.com/android/arch/persistence/room/runtime/1.0.0-alpha/runtime-1.0.0-alpha.pom
https://maven.google.com/android/arch/persistence/room/runtime/1.0.0-alpha/runtime-1.0.0-alpha.jar
https://repo1.maven.org/maven2/android/arch/persistence/room/runtime/1.0.0-alpha/runtime-1.0.0-alpha.pom
https://repo1.maven.org/maven2/android/arch/persistence/room/runtime/1.0.0-alpha/runtime-1.0.0-alpha.jar
Required by:
project :app
> Could not find android.arch.persistence.room:rxjava2:1.0.0-alpha.
Searched in the following locations:
file:/Users/sourabh/Library/Android/sdk/extras/m2repository/android/arch/persistence/room/rxjava2/1.0.0-alpha/rxjava2-1.0.0-alpha.pom
file:/Users/sourabh/Library/Android/sdk/extras/m2repository/android/arch/persistence/room/rxjava2/1.0.0-alpha/rxjava2-1.0.0-alpha.jar
file:/Users/sourabh/Library/Android/sdk/extras/google/m2repository/android/arch/persistence/room/rxjava2/1.0.0-alpha/rxjava2-1.0.0-alpha.pom
file:/Users/sourabh/Library/Android/sdk/extras/google/m2repository/android/arch/persistence/room/rxjava2/1.0.0-alpha/rxjava2-1.0.0-alpha.jar
file:/Users/sourabh/Library/Android/sdk/extras/android/m2repository/android/arch/persistence/room/rxjava2/1.0.0-alpha/rxjava2-1.0.0-alpha.pom
file:/Users/sourabh/Library/Android/sdk/extras/android/m2repository/android/arch/persistence/room/rxjava2/1.0.0-alpha/rxjava2-1.0.0-alpha.jar
https://jcenter.bintray.com/android/arch/persistence/room/rxjava2/1.0.0-alpha/rxjava2-1.0.0-alpha.pom
https://jcenter.bintray.com/android/arch/persistence/room/rxjava2/1.0.0-alpha/rxjava2-1.0.0-alpha.jar
https://maven.google.com/android/arch/persistence/room/rxjava2/1.0.0-alpha/rxjava2-1.0.0-alpha.pom
https://maven.google.com/android/arch/persistence/room/rxjava2/1.0.0-alpha/rxjava2-1.0.0-alpha.jar
https://repo1.maven.org/maven2/android/arch/persistence/room/rxjava2/1.0.0-alpha/rxjava2-1.0.0-alpha.pom
https://repo1.maven.org/maven2/android/arch/persistence/room/rxjava2/1.0.0-alpha/rxjava2-1.0.0-alpha.jar
Required by:
project :app
My build.gradle
file:
buildscript {
ext.kotlin_version = '1.1.2-4'
ext.anko_version = '0.8.2'
ext.compile_sdk_version = 25
ext.min_sdk_version = 16
ext.target_sdk_version = 25
ext.build_tools_version = '25.0.3'
ext.support_lib_version = '25.3.1'
ext.support_lib_play_service = '10.2.0'
ext.constraint_layout_version = '1.0.2'
ext.arch_component_version = '1.0.0-alpha'
ext.rx_kotlin_version = '2.0.3'
ext.rx_android_version = '2.0.1'
ext.dagger_version = '2.10'
ext.ok_http_version = '3.8.0'
ext.retrofit_version = '2.3.0'
ext.glide_version = '3.8.0'
ext.stetho_version = '1.5.0'
ext.chuck_version = '1.0.4'
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My app/build.gradle
file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}
android {
compileSdkVersion compile_sdk_version
buildToolsVersion build_tools_version
defaultConfig {
applicationId "com.sourabhv.leisure"
minSdkVersion min_sdk_version
targetSdkVersion target_sdk_version
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
zipAlignEnabled true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
multiDexEnabled true
applicationIdSuffix ".debug"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "org.jetbrains.anko:anko-common:$anko_version"
compile "com.android.support:appcompat-v7:$support_lib_version"
compile "com.android.support:design:$support_lib_version"
compile "com.android.support:cardview-v7:$support_lib_version"
compile "com.android.support:recyclerview-v7:$support_lib_version"
compile "com.android.support.constraint:constraint-layout:$constraint_layout_version"
compile "io.reactivex.rxjava2:rxkotlin:$rx_kotlin_version"
compile "io.reactivex.rxjava2:rxandroid:$rx_android_version"
compile "android.arch.lifecycle:runtime:$arch_component_version"
compile "android.arch.lifecycle:extensions:$arch_component_version"
annotationProcessor "android.arch.lifecycle:compiler:$arch_component_version"
compile "android.arch.persistence.room:runtime:$arch_component_version"
annotationProcessor "android.arch.persistence.room:compiler:$arch_component_version"
compile "android.arch.persistence.room:rxjava2:$arch_component_version"
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
compile "com.squareup.retrofit2:converter-moshi:$retrofit_version"
compile "com.squareup.okhttp3:okhttp:$ok_http_version"
debugCompile "com.facebook.stetho:stetho:$stetho_version"
debugCompile "com.facebook.stetho:stetho-okhttp3:$stetho_version"
debugCompile "com.readystatesoftware.chuck:library:$chuck_version"
compile "com.github.bumptech.glide:glide:$glide_version"
compile 'com.jakewharton.timber:timber:4.5.1'
compile "com.google.dagger:dagger:$dagger_version"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.